Migrated SectionServiceTests to integration tests

Signed-off-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
Bjarke Berg
2020-09-29 08:14:27 +02:00
parent b06244d4b9
commit d74e18a15d
2 changed files with 10 additions and 11 deletions

View File

@@ -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
/// </summary>
[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<ISectionService>();
private ISectionService SectionService => GetRequiredService<ISectionService>();
private IUserService UserService => GetRequiredService<IUserService>();
[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);
}
}
}

View File

@@ -186,7 +186,6 @@
<Compile Include="Scoping\ScopeTests.cs" />
<Compile Include="Services\CachedDataTypeServiceTests.cs" />
<Compile Include="Services\ConsentServiceTests.cs" />
<Compile Include="Services\SectionServiceTests.cs" />
<Compile Include="TestHelpers\ControllerTesting\AuthenticateEverythingExtensions.cs" />
<Compile Include="TestHelpers\ControllerTesting\AuthenticateEverythingMiddleware.cs" />
<Compile Include="TestHelpers\ControllerTesting\SpecificAssemblyResolver.cs" />
@@ -486,9 +485,6 @@
<Content Include="Services\Importing\uBlogsy-Package.xml" />
<Content Include="Services\Importing\XsltSearch-Package.xml" />
</ItemGroup>
<ItemGroup>
<Folder Include="Web\Validation\" />
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>