From a41323f389ddad25100e42e98929bd7bcae47b2f Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 4 Mar 2021 16:18:57 +1100 Subject: [PATCH] Fixing build and weird protected fields in UmbracoIntegrationTest --- .../CombineGuidBenchmarks.cs | 3 +-- .../CtorInvokeBenchmarks.cs | 3 +-- .../HexStringBenchmarks.cs | 3 +-- .../Testing/UmbracoIntegrationTest.cs | 22 +++++++++---------- .../IBackgroundTaskRunner.cs | 3 +-- .../LatchedBackgroundTaskBase.cs | 3 +-- .../XmlStoreFilePersister.cs | 3 +-- src/Umbraco.Tests/TestHelpers/TestHelper.cs | 1 - .../Web/HttpCookieExtensionsTests.cs | 3 +-- src/Umbraco.Web/AspNet/AspNetIpResolver.cs | 1 - .../UmbracoVirtualNodeByUdiRouteHandler.cs | 3 +-- src/Umbraco.Web/Runtime/WebFinalComposer.cs | 3 +-- src/Umbraco.Web/UmbracoApplication.cs | 3 +-- .../UmbracoDbProviderFactoryCreator.cs | 1 - .../Filters/FeatureAuthorizeAttribute.cs | 3 +-- .../WebApi/HttpRequestMessageExtensions.cs | 1 - 16 files changed, 21 insertions(+), 38 deletions(-) diff --git a/src/Umbraco.Tests.Benchmarks/CombineGuidBenchmarks.cs b/src/Umbraco.Tests.Benchmarks/CombineGuidBenchmarks.cs index 67b6f42250..a27437c6f8 100644 --- a/src/Umbraco.Tests.Benchmarks/CombineGuidBenchmarks.cs +++ b/src/Umbraco.Tests.Benchmarks/CombineGuidBenchmarks.cs @@ -1,7 +1,6 @@ -using System; +using System; using BenchmarkDotNet.Attributes; using Umbraco.Cms.Core; -using Umbraco.Core; using Umbraco.Tests.Benchmarks.Config; namespace Umbraco.Tests.Benchmarks diff --git a/src/Umbraco.Tests.Benchmarks/CtorInvokeBenchmarks.cs b/src/Umbraco.Tests.Benchmarks/CtorInvokeBenchmarks.cs index 34d885a27d..33d8ba371b 100644 --- a/src/Umbraco.Tests.Benchmarks/CtorInvokeBenchmarks.cs +++ b/src/Umbraco.Tests.Benchmarks/CtorInvokeBenchmarks.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; @@ -8,7 +8,6 @@ using BenchmarkDotNet.Diagnosers; using BenchmarkDotNet.Jobs; using Perfolizer.Horology; using Umbraco.Cms.Core; -using Umbraco.Core; namespace Umbraco.Tests.Benchmarks { diff --git a/src/Umbraco.Tests.Benchmarks/HexStringBenchmarks.cs b/src/Umbraco.Tests.Benchmarks/HexStringBenchmarks.cs index d5d079f318..7f6f766aed 100644 --- a/src/Umbraco.Tests.Benchmarks/HexStringBenchmarks.cs +++ b/src/Umbraco.Tests.Benchmarks/HexStringBenchmarks.cs @@ -1,8 +1,7 @@ -using System; +using System; using System.Text; using BenchmarkDotNet.Attributes; using Umbraco.Cms.Core; -using Umbraco.Core; using Umbraco.Tests.Benchmarks.Config; namespace Umbraco.Tests.Benchmarks diff --git a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs index 2487e4d407..03e0ae5b88 100644 --- a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs +++ b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs @@ -88,8 +88,8 @@ namespace Umbraco.Cms.Tests.Integration.Testing } _testTeardown = null; - FirstTestInFixture = false; - FirstTestInSession = false; + _firstTestInFixture = false; + s_firstTestInSession = false; // Ensure CoreRuntime stopped (now it's a HostedService) IHost host = Services.GetRequiredService(); @@ -103,7 +103,7 @@ namespace Umbraco.Cms.Tests.Integration.Testing [SetUp] public virtual void SetUp_Logging() => - TestContext.Progress.Write($"Start test {TestCount++}: {TestContext.CurrentContext.Test.Name}"); + TestContext.Progress.Write($"Start test {s_testCount++}: {TestContext.CurrentContext.Test.Name}"); [SetUp] public virtual void Setup() @@ -245,7 +245,6 @@ namespace Umbraco.Cms.Tests.Integration.Testing { if (TestOptions.Boot) { - Services.GetRequiredService().EnsureBackOfficeSecurity(); Services.GetRequiredService().EnsureUmbracoContext(); } @@ -348,7 +347,7 @@ namespace Umbraco.Cms.Tests.Integration.Testing // Only attach schema once per fixture // Doing it more than once will block the process since the old db hasn't been detached // and it would be the same as NewSchemaPerTest even if it didn't block - if (FirstTestInFixture) + if (_firstTestInFixture) { // New DB + Schema TestDbMeta newSchemaFixtureDbMeta = db.AttachSchema(); @@ -365,7 +364,7 @@ namespace Umbraco.Cms.Tests.Integration.Testing // Only attach schema once per fixture // Doing it more than once will block the process since the old db hasn't been detached // and it would be the same as NewSchemaPerTest even if it didn't block - if (FirstTestInFixture) + if (_firstTestInFixture) { // New DB + Schema TestDbMeta newEmptyFixtureDbMeta = db.AttachEmpty(); @@ -438,12 +437,11 @@ namespace Umbraco.Cms.Tests.Integration.Testing protected IMapperCollection Mappers => Services.GetRequiredService(); - protected UserBuilder UserBuilderInstance = new UserBuilder(); - protected UserGroupBuilder UserGroupBuilderInstance = new UserGroupBuilder(); + protected UserBuilder UserBuilderInstance { get; } = new UserBuilder(); + protected UserGroupBuilder UserGroupBuilderInstance { get; } = new UserGroupBuilder(); - protected static bool FirstTestInSession = true; - - protected bool FirstTestInFixture = true; - protected static int TestCount = 1; + private static bool s_firstTestInSession = true; + private bool _firstTestInFixture = true; + private static int s_testCount = 1; } } diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/IBackgroundTaskRunner.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/IBackgroundTaskRunner.cs index 32a488fb44..52dc75f3fb 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/IBackgroundTaskRunner.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/IBackgroundTaskRunner.cs @@ -1,6 +1,5 @@ -using System; +using System; using Umbraco.Cms.Core; -using Umbraco.Core; namespace Umbraco.Web.Scheduling { diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/LatchedBackgroundTaskBase.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/LatchedBackgroundTaskBase.cs index 46d80dee70..738bed9b5b 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/LatchedBackgroundTaskBase.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/LegacyBackgroundTask/LatchedBackgroundTaskBase.cs @@ -1,8 +1,7 @@ -using System; +using System; using System.Threading; using System.Threading.Tasks; using Umbraco.Cms.Core; -using Umbraco.Core; namespace Umbraco.Web.Scheduling { diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlStoreFilePersister.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlStoreFilePersister.cs index 58900dea5f..6029a069cb 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlStoreFilePersister.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlStoreFilePersister.cs @@ -1,8 +1,7 @@ -using System; +using System; using System.Threading; using Microsoft.Extensions.Logging; using Umbraco.Cms.Core; -using Umbraco.Core; using Umbraco.Web.Scheduling; namespace Umbraco.Tests.LegacyXmlPublishedCache diff --git a/src/Umbraco.Tests/TestHelpers/TestHelper.cs b/src/Umbraco.Tests/TestHelpers/TestHelper.cs index cd9a9a78ce..1a0e9a03d2 100644 --- a/src/Umbraco.Tests/TestHelpers/TestHelper.cs +++ b/src/Umbraco.Tests/TestHelpers/TestHelper.cs @@ -38,7 +38,6 @@ using Umbraco.Cms.Infrastructure.Migrations.Install; using Umbraco.Cms.Infrastructure.Persistence; using Umbraco.Cms.Persistence.SqlCe; using Umbraco.Cms.Tests.Common; -using Umbraco.Core; using Umbraco.Extensions; using Umbraco.Web; using Umbraco.Web.Hosting; diff --git a/src/Umbraco.Tests/Web/HttpCookieExtensionsTests.cs b/src/Umbraco.Tests/Web/HttpCookieExtensionsTests.cs index 73b5987407..3964017e57 100644 --- a/src/Umbraco.Tests/Web/HttpCookieExtensionsTests.cs +++ b/src/Umbraco.Tests/Web/HttpCookieExtensionsTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; @@ -6,7 +6,6 @@ using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; using NUnit.Framework; -using Umbraco.Core; using Umbraco.Web; namespace Umbraco.Tests.Web diff --git a/src/Umbraco.Web/AspNet/AspNetIpResolver.cs b/src/Umbraco.Web/AspNet/AspNetIpResolver.cs index 5a14592aaf..6a5766e5c4 100644 --- a/src/Umbraco.Web/AspNet/AspNetIpResolver.cs +++ b/src/Umbraco.Web/AspNet/AspNetIpResolver.cs @@ -1,6 +1,5 @@ using System.Web; using Umbraco.Cms.Core.Net; -using Umbraco.Core; namespace Umbraco.Web { diff --git a/src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs b/src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs index c74045c0d2..3ba24945b7 100644 --- a/src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs +++ b/src/Umbraco.Web/Mvc/UmbracoVirtualNodeByUdiRouteHandler.cs @@ -1,8 +1,7 @@ -using System.Web.Routing; +using System.Web.Routing; using Umbraco.Cms.Core; using Umbraco.Cms.Core.Models.PublishedContent; using Umbraco.Cms.Core.Web; -using Umbraco.Core; namespace Umbraco.Web.Mvc { diff --git a/src/Umbraco.Web/Runtime/WebFinalComposer.cs b/src/Umbraco.Web/Runtime/WebFinalComposer.cs index 2c2a2423e6..818bff521a 100644 --- a/src/Umbraco.Web/Runtime/WebFinalComposer.cs +++ b/src/Umbraco.Web/Runtime/WebFinalComposer.cs @@ -1,5 +1,4 @@ -using Umbraco.Cms.Core.Composing; -using Umbraco.Core; +using Umbraco.Cms.Core.Composing; namespace Umbraco.Web.Runtime { diff --git a/src/Umbraco.Web/UmbracoApplication.cs b/src/Umbraco.Web/UmbracoApplication.cs index 8bc0720606..327537ee00 100644 --- a/src/Umbraco.Web/UmbracoApplication.cs +++ b/src/Umbraco.Web/UmbracoApplication.cs @@ -1,8 +1,7 @@ -using System.Runtime.InteropServices; +using System.Runtime.InteropServices; using System.Web; using Microsoft.Extensions.Logging; using Umbraco.Cms.Core.Logging; -using Umbraco.Core; using Umbraco.Web.Runtime; using ConnectionStrings = Umbraco.Cms.Core.Configuration.Models.ConnectionStrings; diff --git a/src/Umbraco.Web/UmbracoDbProviderFactoryCreator.cs b/src/Umbraco.Web/UmbracoDbProviderFactoryCreator.cs index d0f63f5242..04dba05a90 100644 --- a/src/Umbraco.Web/UmbracoDbProviderFactoryCreator.cs +++ b/src/Umbraco.Web/UmbracoDbProviderFactoryCreator.cs @@ -5,7 +5,6 @@ using Umbraco.Cms.Infrastructure.Migrations.Install; using Umbraco.Cms.Infrastructure.Persistence; using Umbraco.Cms.Infrastructure.Persistence.SqlSyntax; using Umbraco.Cms.Persistence.SqlCe; -using Umbraco.Core; using Constants = Umbraco.Cms.Core.Constants; namespace Umbraco.Web diff --git a/src/Umbraco.Web/WebApi/Filters/FeatureAuthorizeAttribute.cs b/src/Umbraco.Web/WebApi/Filters/FeatureAuthorizeAttribute.cs index af5987757d..bae3ad05c2 100644 --- a/src/Umbraco.Web/WebApi/Filters/FeatureAuthorizeAttribute.cs +++ b/src/Umbraco.Web/WebApi/Filters/FeatureAuthorizeAttribute.cs @@ -1,7 +1,6 @@ -using System.Web.Http; +using System.Web.Http; using System.Web.Http.Controllers; using Umbraco.Web.Composing; -using Umbraco.Core; using Microsoft.Extensions.DependencyInjection; using Umbraco.Cms.Core.Features; diff --git a/src/Umbraco.Web/WebApi/HttpRequestMessageExtensions.cs b/src/Umbraco.Web/WebApi/HttpRequestMessageExtensions.cs index 0c55db10a4..2d53393d21 100644 --- a/src/Umbraco.Web/WebApi/HttpRequestMessageExtensions.cs +++ b/src/Umbraco.Web/WebApi/HttpRequestMessageExtensions.cs @@ -4,7 +4,6 @@ using System.Net.Http; using System.Web; using Microsoft.Owin; using Umbraco.Cms.Core; -using Umbraco.Core; namespace Umbraco.Web.WebApi {