From ed253423110268d336734898f1d1923c66eb6347 Mon Sep 17 00:00:00 2001 From: Bjarke Berg Date: Tue, 21 Feb 2023 11:28:21 +0100 Subject: [PATCH] Fixed tess --- .../TestServerTest/UmbracoTestServerTestBase.cs | 7 +++++-- .../Testing/TestWebProfilerRepository.cs | 12 ++++++++++++ .../Testing/UmbracoIntegrationTest.cs | 4 ++++ .../TestHelpers/Objects/TestUmbracoContextFactory.cs | 4 +++- 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 tests/Umbraco.Tests.Integration/Testing/TestWebProfilerRepository.cs diff --git a/tests/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs b/tests/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs index dfe7b9377b..ab786a9911 100644 --- a/tests/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs +++ b/tests/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs @@ -18,6 +18,7 @@ using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Web; using Umbraco.Cms.Api.Management; using Umbraco.Cms.Api.Management.Controllers.Install; +using Umbraco.Cms.Core.Persistence.Repositories; using Umbraco.Cms.Persistence.Sqlite; using Umbraco.Cms.Persistence.SqlServer; using Umbraco.Cms.Tests.Common.Testing; @@ -77,10 +78,12 @@ namespace Umbraco.Cms.Tests.Integration.TestServerTest // Executes after the standard ConfigureServices method builder.ConfigureTestServices(services => - + { // Add a test auth scheme with a test auth handler to authn and assign the user services.AddAuthentication(TestAuthHandler.TestAuthenticationScheme) - .AddScheme(TestAuthHandler.TestAuthenticationScheme, options => { })); + .AddScheme( + TestAuthHandler.TestAuthenticationScheme, options => { }); + }); }); Client = Factory.CreateClient(new WebApplicationFactoryClientOptions diff --git a/tests/Umbraco.Tests.Integration/Testing/TestWebProfilerRepository.cs b/tests/Umbraco.Tests.Integration/Testing/TestWebProfilerRepository.cs new file mode 100644 index 0000000000..3d5dbb2e2b --- /dev/null +++ b/tests/Umbraco.Tests.Integration/Testing/TestWebProfilerRepository.cs @@ -0,0 +1,12 @@ +using Umbraco.Cms.Core.Persistence.Repositories; + +namespace Umbraco.Cms.Tests.Integration.Testing; + +public class TestWebProfilerRepository : IWebProfilerRepository +{ + private bool _status = false; + + public void SetStatus(int userId, bool status) => _status = status; + + public bool GetStatus(int userId) => _status; +} diff --git a/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs index c83b13e0fe..c44c908fe8 100644 --- a/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs +++ b/tests/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs @@ -8,6 +8,7 @@ using NUnit.Framework; using Umbraco.Cms.Core.Cache; using Umbraco.Cms.Core.Configuration.Models; using Umbraco.Cms.Core.IO; +using Umbraco.Cms.Core.Persistence.Repositories; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Strings; using Umbraco.Cms.Core.Web; @@ -19,6 +20,7 @@ using Umbraco.Cms.Persistence.SqlServer; using Umbraco.Cms.Tests.Common.Builders; using Umbraco.Cms.Tests.Integration.DependencyInjection; using Umbraco.Cms.Tests.Integration.Extensions; +using Umbraco.Cms.Tests.Integration.TestServerTest; using Constants = Umbraco.Cms.Core.Constants; namespace Umbraco.Cms.Tests.Integration.Testing; @@ -129,7 +131,9 @@ public abstract class UmbracoIntegrationTest : UmbracoIntegrationTestBase // We register this service because we need it for IRuntimeState, if we don't this breaks 900 tests services.AddSingleton(); + services.AddSingleton(); + services.AddLogger(webHostEnvironment, Configuration); // Add it! diff --git a/tests/Umbraco.Tests.UnitTests/TestHelpers/Objects/TestUmbracoContextFactory.cs b/tests/Umbraco.Tests.UnitTests/TestHelpers/Objects/TestUmbracoContextFactory.cs index 2099d1d537..9e663fa9bc 100644 --- a/tests/Umbraco.Tests.UnitTests/TestHelpers/Objects/TestUmbracoContextFactory.cs +++ b/tests/Umbraco.Tests.UnitTests/TestHelpers/Objects/TestUmbracoContextFactory.cs @@ -7,6 +7,7 @@ using Moq; using Umbraco.Cms.Core.Configuration.Models; using Umbraco.Cms.Core.PublishedCache; using Umbraco.Cms.Core.Routing; +using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Web; using Umbraco.Cms.Tests.Common; using Umbraco.Cms.Web.Common.AspNetCore; @@ -68,7 +69,8 @@ public class TestUmbracoContextFactory hostingEnvironment, new UriUtility(hostingEnvironment), new AspNetCoreCookieManager(httpContextAccessor), - httpContextAccessor); + httpContextAccessor, + Mock.Of()); return umbracoContextFactory; }