fixes tests

This commit is contained in:
Shannon
2017-08-23 15:20:12 +10:00
parent 8982f7b933
commit f457edfada
2 changed files with 11 additions and 3 deletions

View File

@@ -43,6 +43,9 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
var owinContext = request.GetOwinContext();
var mockedUserService = Mock.Of<IUserService>();
var mockedContentService = Mock.Of<IContentService>();
var mockedMediaService = Mock.Of<IMediaService>();
var mockedEntityService = Mock.Of<IEntityService>();
var mockedMigrationService = new Mock<IMigrationEntryService>();
//set it up to return anything so that the app ctx is 'Configured'
@@ -50,6 +53,9 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
var serviceContext = new ServiceContext(
userService: mockedUserService,
contentService: mockedContentService,
mediaService: mockedMediaService,
entityService: mockedEntityService,
migrationEntryService: mockedMigrationService.Object,
localizedTextService:Mock.Of<ILocalizedTextService>(),
sectionService:Mock.Of<ISectionService>());

View File

@@ -11,6 +11,7 @@ using Umbraco.Core.Models;
using Umbraco.Core.Models.Identity;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Persistence.DatabaseModelDefinitions;
using Umbraco.Core.Persistence.Querying;
using Umbraco.Core.Security;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.TestHelpers.ControllerTesting;
@@ -35,7 +36,6 @@ namespace Umbraco.Tests.Web.Controllers
Umbraco.Core.Configuration.GlobalSettings.HasSmtpServer = true;
var userServiceMock = Mock.Get(helper.UmbracoContext.Application.Services.UserService);
userServiceMock.Setup(service => service.Save(It.IsAny<IUser>(), It.IsAny<bool>()))
.Callback((IUser u, bool raiseEvents) =>
{
@@ -47,7 +47,7 @@ namespace Umbraco.Tests.Web.Controllers
.Returns(new[] { Mock.Of<IUserGroup>(group => group.Id == 123 && group.Alias == "writers" && group.Name == "Writers") });
userServiceMock.Setup(service => service.GetUserById(It.IsAny<int>()))
.Returns(new User(1234, "Test", "test@test.com", "test@test.com", "", new List<IReadOnlyUserGroup>(), new int[0], new int[0]));
//we need to manually apply automapper mappings with the mocked applicationcontext
InitializeMappers(helper.UmbracoContext.Application);
@@ -104,7 +104,9 @@ namespace Umbraco.Tests.Web.Controllers
var userServiceMock = Mock.Get(helper.UmbracoContext.Application.Services.UserService);
var users = MockedUser.CreateMulipleUsers(10);
long outVal = 10;
userServiceMock.Setup(service => service.GetAll(It.IsAny<long>(), It.IsAny<int>(), out outVal, It.IsAny<string>(), It.IsAny<Direction>(), It.IsAny<UserState[]>(), It.IsAny<string[]>(), It.IsAny<string>()))
userServiceMock.Setup(service => service.GetAll(
It.IsAny<long>(), It.IsAny<int>(), out outVal, It.IsAny<string>(), It.IsAny<Direction>(),
It.IsAny<UserState[]>(), It.IsAny<string[]>(), It.IsAny<string[]>(), It.IsAny<IQuery<IUser>>()))
.Returns(() => users);
//we need to manually apply automapper mappings with the mocked applicationcontext