Merge remote-tracking branch 'origin/netcore/netcore' into netcore/feature/migrate-logging

Signed-off-by: Bjarke Berg <mail@bergmania.dk>

# Conflicts:
#	src/Umbraco.Infrastructure/Runtime/CoreInitialComposer.cs
#	src/Umbraco.Tests.Integration/Packaging/CreatedPackagesRepositoryTests.cs
#	src/Umbraco.Tests.Integration/Services/CachedDataTypeServiceTests.cs
#	src/Umbraco.Tests.Integration/Services/DataTypeServiceTests.cs
#	src/Umbraco.Tests.Integration/Services/MacroServiceTests.cs
#	src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
#	src/Umbraco.Tests.UnitTests/Umbraco.Core/Services/LocalizedTextServiceTests.cs
This commit is contained in:
Bjarke Berg
2020-10-06 18:47:12 +02:00
39 changed files with 800 additions and 903 deletions

View File

@@ -26,7 +26,7 @@ namespace Umbraco.Tests.Common.Builders
private string _icon;
private string _name;
private IEnumerable<string> _permissions = Enumerable.Empty<string>();
private IEnumerable<string> _sectionCollection = Enumerable.Empty<string>();
private IEnumerable<string> _allowedSections = Enumerable.Empty<string>();
private string _suffix;
private int? _startContentId;
private int? _startMediaId;
@@ -55,7 +55,7 @@ namespace Umbraco.Tests.Common.Builders
public UserGroupBuilder<TParent> WithPermissions(string permissions)
{
_permissions = permissions.Split();
_permissions = permissions.ToCharArray().Select(x => x.ToString());
return this;
}
@@ -65,6 +65,12 @@ namespace Umbraco.Tests.Common.Builders
return this;
}
public UserGroupBuilder<TParent> WithAllowedSections(IList<string> allowedSections)
{
_allowedSections = allowedSections;
return this;
}
public UserGroupBuilder<TParent> WithStartContentId(int startContentId)
{
_startContentId = startContentId;
@@ -107,9 +113,9 @@ namespace Umbraco.Tests.Common.Builders
userGroup.StartContentId = startContentId;
userGroup.StartMediaId = startMediaId;
foreach (var item in _sectionCollection)
foreach (var section in _allowedSections)
{
userGroup.AddAllowedSection(item);
userGroup.AddAllowedSection(section);
}
return userGroup;

View File

@@ -1,62 +0,0 @@
using Moq;
using System;
using System.Collections.Generic;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Models.Membership;
namespace Umbraco.Tests.Common.TestHelpers.Entities
{
public static class MockedUser
{
/// <summary>
/// Returns a <see cref="Mock{IUser}"/> and ensures that the ToUserCache and FromUserCache methods are mapped correctly for
/// dealing with start node caches
/// </summary>
/// <returns></returns>
public static Mock<IUser> GetUserMock()
{
var userCache = new Dictionary<string, object>();
var userMock = new Mock<IUser>();
userMock.Setup(x => x.FromUserCache<int[]>(It.IsAny<string>())).Returns((string key) => userCache.TryGetValue(key, out var val) ? val is int[] iVal ? iVal : null : null);
userMock.Setup(x => x.ToUserCache<int[]>(It.IsAny<string>(), It.IsAny<int[]>())).Callback((string key, int[] val) => userCache[key] = val);
return userMock;
}
public static User CreateUser(string suffix = "")
{
var globalSettings = new GlobalSettings();
var user = new User(globalSettings)
{
Language = "en",
IsApproved = true,
Name = "TestUser" + suffix,
RawPasswordValue = "testing",
IsLockedOut = false,
Email = "test" + suffix + "@test.com",
Username = "TestUser" + suffix
};
return user;
}
public static IEnumerable<IUser> CreateMulipleUsers(int amount, Action<int, IUser> onCreating = null)
{
var list = new List<IUser>();
var globalSettings = new GlobalSettings();
for (var i = 0; i < amount; i++)
{
var name = "Member No-" + i;
var user = new User(globalSettings, name, "test" + i + "@test.com", "test" + i, "test" + i);
onCreating?.Invoke(i, user);
user.ResetDirtyProperties(false);
list.Add(user);
}
return list;
}
}
}