Moved unit tests to right project + Cleanup + Write info in test console

Signed-off-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
Bjarke Berg
2020-10-27 14:10:19 +01:00
parent a09e218501
commit 765140b7cd
11 changed files with 26 additions and 57 deletions

View File

@@ -76,15 +76,22 @@ namespace Umbraco.Tests.Integration.Testing
_testTeardown = null;
FirstTestInFixture = false;
FirstTestInSession = false;
}
[TearDown]
public virtual void TearDown_Logging()
{
TestContext.Progress.Write($" {TestContext.CurrentContext.Result.Outcome.Status}");
}
[SetUp]
public virtual void SetUp_Logging()
{
TestContext.Progress.Write($"Start test {TestCount++}: {TestContext.CurrentContext.Test.Name}");
}
[SetUp]
public virtual void Setup()
{
TestContext.Progress.Write($"Start test {_testCount++}: {TestContext.CurrentContext.Test.Name}");
var hostBuilder = CreateHostBuilder();
var host = hostBuilder.Start();
@@ -433,7 +440,7 @@ namespace Umbraco.Tests.Integration.Testing
#endregion
#region Common services
protected virtual T GetRequiredService<T>() => Services.GetRequiredService<T>();
public Dictionary<string, string> InMemoryConfiguration { get; } = new Dictionary<string, string>();
@@ -484,6 +491,6 @@ namespace Umbraco.Tests.Integration.Testing
protected static bool FirstTestInSession = true;
protected bool FirstTestInFixture = true;
private static int _testCount = 1;
protected static int TestCount = 1;
}
}

View File

@@ -1,4 +1,5 @@
using System;
using NUnit.Framework;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Core.Services.Implement;
@@ -12,9 +13,8 @@ namespace Umbraco.Tests.Integration.Testing
protected IFileService FileService => GetRequiredService<IFileService>();
protected ContentService ContentService => (ContentService)GetRequiredService<IContentService>();
public override void Setup()
{
base.Setup();
[SetUp]
public void Setup(){
CreateTestData();
}

View File

@@ -392,11 +392,5 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor
Assert.That(doesntExist, Is.False);
}
}
[TearDown]
public override void TearDown()
{
base.TearDown();
}
}
}

View File

@@ -47,11 +47,10 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor
ContentRepositoryBase.ThrowOnWarning = true;
}
public override void TearDown()
[TearDown]
public void Teardown()
{
ContentRepositoryBase.ThrowOnWarning = false;
base.TearDown();
}
public void CreateTestData()

View File

@@ -410,12 +410,6 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositor
}
}
[TearDown]
public override void TearDown()
{
base.TearDown();
}
public void CreateTestData()
{
_relateContent = new RelationType(

View File

@@ -47,10 +47,10 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
ContentTypeService.Save(_contentType);
}
public override void TearDown()
[TearDown]
public void Teardown()
{
ContentRepositoryBase.ThrowOnWarning = false;
base.TearDown();
}
[Test]

View File

@@ -264,12 +264,6 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
}
}
[TearDown]
public override void TearDown()
{
base.TearDown();
}
public void CreateTestData()
{

View File

@@ -28,16 +28,16 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
private IFileService FileService => GetRequiredService<IFileService>();
public PropertyEditorCollection PropertyEditorCollection => GetRequiredService<PropertyEditorCollection>();
public override void Setup()
[SetUp]
public void Setup()
{
base.Setup();
ContentRepositoryBase.ThrowOnWarning = true;
}
public override void TearDown()
[TearDown]
public void Teardown()
{
ContentRepositoryBase.ThrowOnWarning = false;
base.TearDown();
}
[Test]

View File

@@ -48,16 +48,16 @@ namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Services
private PropertyEditorCollection PropertyEditorCollection => GetRequiredService<PropertyEditorCollection>();
private IDocumentRepository DocumentRepository => GetRequiredService<IDocumentRepository>();
public override void Setup()
[SetUp]
public void Setup()
{
base.Setup();
ContentRepositoryBase.ThrowOnWarning = true;
}
public override void TearDown()
[TearDown]
public void Teardown()
{
ContentRepositoryBase.ThrowOnWarning = false;
base.TearDown();
}
[Test]

View File

@@ -8,7 +8,6 @@ using Umbraco.Core.Cache;
using Umbraco.Core.Configuration.Models;
using Umbraco.Core.Hosting;
using Umbraco.Extensions;
using Umbraco.Tests.Integration.Implementations;
using Umbraco.Web;
using Umbraco.Web.BackOffice.Controllers;
using Umbraco.Web.BackOffice.Security;
@@ -21,9 +20,6 @@ namespace Umbraco.Tests.Integration.Umbraco.Web.Backoffice.Security
[Test]
public void ShouldAuthenticateRequest_When_Not_Configured()
{
var testHelper = new TestHelper();
var httpContextAccessor = testHelper.GetHttpContextAccessor();
var globalSettings = new GlobalSettings();
var runtime = Mock.Of<IRuntimeState>(x => x.Level == RuntimeLevel.Install);
@@ -43,12 +39,6 @@ namespace Umbraco.Tests.Integration.Umbraco.Web.Backoffice.Security
[Test]
public void ShouldAuthenticateRequest_When_Configured()
{
var testHelper = new TestHelper();
//hostingEnvironment.ToAbsolute(globalSettings.UmbracoPath);
var httpContextAccessor = testHelper.GetHttpContextAccessor();
var globalSettings = new GlobalSettings();
var runtime = Mock.Of<IRuntimeState>(x => x.Level == RuntimeLevel.Run);
@@ -68,9 +58,6 @@ namespace Umbraco.Tests.Integration.Umbraco.Web.Backoffice.Security
[Test]
public void ShouldAuthenticateRequest_Is_Back_Office()
{
var testHelper = new TestHelper();
var httpContextAccessor = testHelper.GetHttpContextAccessor();
var globalSettings = new GlobalSettings();
var runtime = Mock.Of<IRuntimeState>(x => x.Level == RuntimeLevel.Run);
@@ -93,9 +80,6 @@ namespace Umbraco.Tests.Integration.Umbraco.Web.Backoffice.Security
[Test]
public void ShouldAuthenticateRequest_Force_Auth()
{
var testHelper = new TestHelper();
var httpContextAccessor = testHelper.GetHttpContextAccessor();
var globalSettings = new GlobalSettings();
var runtime = Mock.Of<IRuntimeState>(x => x.Level == RuntimeLevel.Run);
@@ -115,9 +99,6 @@ namespace Umbraco.Tests.Integration.Umbraco.Web.Backoffice.Security
[Test]
public void ShouldAuthenticateRequest_Not_Back_Office()
{
var testHelper = new TestHelper();
var httpContextAccessor = testHelper.GetHttpContextAccessor();
var globalSettings = new GlobalSettings();
var runtime = Mock.Of<IRuntimeState>(x => x.Level == RuntimeLevel.Run);