From d74e18a15d833ebe0b295e6d5bf2c899bb4a2605 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Tue, 29 Sep 2020 08:14:27 +0200 Subject: [PATCH] Migrated SectionServiceTests to integration tests Signed-off-by: Bjarke Berg --- .../Services/SectionServiceTests.cs | 17 ++++++++++------- src/Umbraco.Tests/Umbraco.Tests.csproj | 4 ---- 2 files changed, 10 insertions(+), 11 deletions(-) rename src/{Umbraco.Tests => Umbraco.Tests.Integration}/Services/SectionServiceTests.cs (76%) diff --git a/src/Umbraco.Tests/Services/SectionServiceTests.cs b/src/Umbraco.Tests.Integration/Services/SectionServiceTests.cs similarity index 76% rename from src/Umbraco.Tests/Services/SectionServiceTests.cs rename to src/Umbraco.Tests.Integration/Services/SectionServiceTests.cs index 032d317ebc..533a66ad96 100644 --- a/src/Umbraco.Tests/Services/SectionServiceTests.cs +++ b/src/Umbraco.Tests.Integration/Services/SectionServiceTests.cs @@ -5,7 +5,9 @@ using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Core.Configuration.Models; using Umbraco.Core.Models.Membership; +using Umbraco.Core.Services; using Umbraco.Tests.Common.Builders; +using Umbraco.Tests.Integration.Testing; using Umbraco.Tests.Testing; using Umbraco.Web.Services; @@ -16,10 +18,11 @@ namespace Umbraco.Tests.Services /// [TestFixture] [Apartment(ApartmentState.STA)] - [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, WithApplication = true)] - public class SectionServiceTests : TestWithSomeContentBase + [UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)] + public class SectionServiceTests : UmbracoIntegrationTest { - private ISectionService SectionService => Factory.GetInstance(); + private ISectionService SectionService => GetRequiredService(); + private IUserService UserService => GetRequiredService(); [Test] public void SectionService_Can_Get_Allowed_Sections_For_User() @@ -43,7 +46,7 @@ namespace Umbraco.Tests.Services Username = "testUser", Email = "testuser@test.com", }; - ServiceContext.UserService.Save(user, false); + UserService.Save(user, false); var userGroupA = new UserGroup(ShortStringHelper) { @@ -53,7 +56,7 @@ namespace Umbraco.Tests.Services userGroupA.AddAllowedSection("media"); userGroupA.AddAllowedSection("settings"); // TODO: This is failing the test - ServiceContext.UserService.Save(userGroupA, new[] { user.Id }, false); + UserService.Save(userGroupA, new[] { user.Id }, false); var userGroupB = new UserGroup(ShortStringHelper) { @@ -62,9 +65,9 @@ namespace Umbraco.Tests.Services }; userGroupB.AddAllowedSection("settings"); userGroupB.AddAllowedSection("member"); - ServiceContext.UserService.Save(userGroupB, new[] { user.Id }, false); + UserService.Save(userGroupB, new[] { user.Id }, false); - return ServiceContext.UserService.GetUserById(user.Id); + return UserService.GetUserById(user.Id); } } } diff --git a/src/Umbraco.Tests/Umbraco.Tests.csproj b/src/Umbraco.Tests/Umbraco.Tests.csproj index 9ed8e20494..70720a588a 100644 --- a/src/Umbraco.Tests/Umbraco.Tests.csproj +++ b/src/Umbraco.Tests/Umbraco.Tests.csproj @@ -186,7 +186,6 @@ - @@ -486,9 +485,6 @@ - - -