Merge branch 'v10/dev' into v10/feature/variant-permissions

This commit is contained in:
Zeegaan
2022-07-04 14:43:09 +02:00
54 changed files with 1565 additions and 692 deletions

View File

@@ -0,0 +1,78 @@
/// <reference types="Cypress" />
import {
ContentBuilder,
DocumentTypeBuilder,
} from 'umbraco-cypress-testhelpers';
context('Recycle bin', () => {
beforeEach(() => {
cy.umbracoLogin(Cypress.env('username'), Cypress.env('password'));
});
function refreshContentTree() {
// Refresh to update the tree
cy.get('li .umb-tree-root:contains("Content")').should("be.visible").rightclick();
cy.umbracoContextMenuAction("action-refreshNode").click();
// We have to wait in case the execution is slow, otherwise we'll try and click the item before it appears in the UI
cy.get('.umb-tree-item__inner').should('exist', { timeout: 10000 });
}
it('Can delete content from recycle bin', () => {
const contentToDeleteName = "DeleteMe";
const contentToNotDeleteName = "DontDelete";
const testType = "TestType";
cy.umbracoEnsureDocumentTypeNameNotExists(testType);
cy.deleteAllContent();
const docType = new DocumentTypeBuilder()
.withName(testType)
.build();
cy.saveDocumentType(docType).then((savedDocType) => {
const contentToDelete = new ContentBuilder()
.withContentTypeAlias(savedDocType.alias)
.withAction("saveNew")
.addVariant()
.withName(contentToDeleteName)
.withSave(true)
.done()
.build();
const contentToNotDelete = new ContentBuilder()
.withContentTypeAlias(savedDocType.alias)
.withAction("saveNew")
.addVariant()
.withName(contentToNotDeleteName)
.withSave(true)
.done()
.build();
// Put it in the recycle bin
cy.saveContent(contentToDelete).then(savedToDelete => {
cy.deleteContentById(savedToDelete.id);
});
cy.saveContent(contentToNotDelete).then(savedNotToDelete => {
cy.deleteContentById(savedNotToDelete.id)
});
});
refreshContentTree();
cy.umbracoTreeItem('content', ["Recycle Bin"]).click();
cy.get('.umb-content-grid__content').contains(contentToDeleteName).closest('div').click();
cy.umbracoButtonByLabelKey('actions_delete').click();
cy.umbracoButtonByLabelKey('contentTypeEditor_yesDelete').click();
cy.umbracoSuccessNotification().should('be.visible');
cy.get('.umb-content-grid__content').contains(contentToDeleteName).should('not.exist');
cy.umbracoTreeItem('content', ["Recycle Bin", contentToDeleteName]).should('not.exist');
cy.get('.umb-content-grid__content').contains(contentToNotDeleteName).should('be.visible');
cy.umbracoTreeItem('content', ["Recycle Bin", contentToNotDeleteName]).should('be.visible');
cy.deleteAllContent();
cy.umbracoEnsureDocumentTypeNameNotExists(testType);
});
});

View File

@@ -24,7 +24,7 @@ COPY --from=build dist .
ENV ASPNETCORE_URLS="http://0.0.0.0:5000"
ENV Umbraco__CMS__Global__InstallMissingDatabase="true"
ENV ConnectionStrings__umbracoDbDSN_ProviderName="Microsoft.Data.SQLite"
ENV ConnectionStrings__umbracoDbDSN_ProviderName="Microsoft.Data.Sqlite"
ENV ConnectionStrings__umbracoDbDSN="Data Source=|DataDirectory|/Umbraco.sqlite.db;Cache=Shared;Foreign Keys=True;Pooling=True"
ENV Umbraco__CMS__Unattended__InstallUnattended="true"
ENV Umbraco__CMS__Unattended__UnattendedUserName="Cypress Test"

View File

@@ -15,6 +15,7 @@ using Microsoft.Extensions.Hosting;
using Moq;
using NUnit.Framework;
using Umbraco.Cms.Core.Cache;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Web;
@@ -29,231 +30,247 @@ using Umbraco.Cms.Web.Common.Hosting;
using Umbraco.Cms.Web.Website.Controllers;
using Umbraco.Extensions;
namespace Umbraco.Cms.Tests.Integration.TestServerTest;
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, Logger = UmbracoTestOptions.Logger.Console, Boot = true)]
public abstract class UmbracoTestServerTestBase : UmbracoIntegrationTestBase
namespace Umbraco.Cms.Tests.Integration.TestServerTest
{
[SetUp]
public void Setup()
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, Logger = UmbracoTestOptions.Logger.Console, Boot = true)]
public abstract class UmbracoTestServerTestBase : UmbracoIntegrationTestBase
{
/*
* It's worth noting that our usage of WebApplicationFactory is non-standard,
* the intent is that your Startup.ConfigureServices is called just like
* when the app starts up, then replacements are registered in this class with
* builder.ConfigureServices (builder.ConfigureTestServices has hung around from before the
* generic host switchover).
*
* This is currently a pain to refactor towards due to UmbracoBuilder+TypeFinder+TypeLoader setup but
* we should get there one day.
*
* However we need to separate the testing framework we provide for downstream projects from our own tests.
* We cannot use the Umbraco.Web.UI startup yet as that is not available downstream.
*
* See https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests
*/
var factory = new UmbracoWebApplicationFactory<UmbracoTestServerTestBase>(CreateHostBuilder);
protected HttpClient Client { get; private set; }
// additional host configuration for web server integration tests
Factory = factory.WithWebHostBuilder(builder =>
protected LinkGenerator LinkGenerator { get; private set; }
protected WebApplicationFactory<UmbracoTestServerTestBase> Factory { get; private set; }
/// <summary>
/// Hook for altering UmbracoBuilder setup
/// </summary>
/// <remarks>
/// Can also be used for registering test doubles.
/// </remarks>
protected virtual void CustomTestSetup(IUmbracoBuilder builder)
{
// Otherwise inferred as $(SolutionDir)/Umbraco.Tests.Integration (note lack of src/tests)
builder.UseContentRoot(Assembly.GetExecutingAssembly().GetRootDirectorySafe());
}
// 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<AuthenticationSchemeOptions, TestAuthHandler>(TestAuthHandler.TestAuthenticationScheme, options => { }));
});
Client = Factory.CreateClient(new WebApplicationFactoryClientOptions { AllowAutoRedirect = false });
LinkGenerator = Factory.Services.GetRequiredService<LinkGenerator>();
}
protected HttpClient Client { get; private set; }
protected LinkGenerator LinkGenerator { get; private set; }
protected WebApplicationFactory<UmbracoTestServerTestBase> Factory { get; private set; }
/// <summary>
/// Prepare a url before using <see cref="Client" />.
/// This returns the url but also sets the HttpContext.request into to use this url.
/// </summary>
/// <returns>The string URL of the controller action.</returns>
protected string PrepareApiControllerUrl<T>(Expression<Func<T, object>> methodSelector)
where T : UmbracoApiController
{
var url = LinkGenerator.GetUmbracoApiService(methodSelector);
return PrepareUrl(url);
}
/// <summary>
/// Prepare a url before using <see cref="Client" />.
/// This returns the url but also sets the HttpContext.request into to use this url.
/// </summary>
/// <returns>The string URL of the controller action.</returns>
protected string PrepareSurfaceControllerUrl<T>(Expression<Func<T, object>> methodSelector)
where T : SurfaceController
{
var url = LinkGenerator.GetUmbracoSurfaceUrl(methodSelector);
return PrepareUrl(url);
}
/// <summary>
/// Prepare a url before using <see cref="Client" />.
/// This returns the url but also sets the HttpContext.request into to use this url.
/// </summary>
/// <returns>The string URL of the controller action.</returns>
protected string PrepareUrl(string url)
{
var umbracoContextFactory = GetRequiredService<IUmbracoContextFactory>();
var httpContextAccessor = GetRequiredService<IHttpContextAccessor>();
httpContextAccessor.HttpContext = new DefaultHttpContext
[SetUp]
public void Setup()
{
Request =
/*
* It's worth noting that our usage of WebApplicationFactory is non-standard,
* the intent is that your Startup.ConfigureServices is called just like
* when the app starts up, then replacements are registered in this class with
* builder.ConfigureServices (builder.ConfigureTestServices has hung around from before the
* generic host switchover).
*
* This is currently a pain to refactor towards due to UmbracoBuilder+TypeFinder+TypeLoader setup but
* we should get there one day.
*
* However we need to separate the testing framework we provide for downstream projects from our own tests.
* We cannot use the Umbraco.Web.UI startup yet as that is not available downstream.
*
* See https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests
*/
var factory = new UmbracoWebApplicationFactory<UmbracoTestServerTestBase>(CreateHostBuilder);
// additional host configuration for web server integration tests
Factory = factory.WithWebHostBuilder(builder =>
{
Scheme = "https",
Host = new HostString("localhost", 80),
Path = url,
QueryString = new QueryString(string.Empty)
}
};
// Otherwise inferred as $(SolutionDir)/Umbraco.Tests.Integration (note lack of src/tests)
builder.UseContentRoot(Assembly.GetExecutingAssembly().GetRootDirectorySafe());
umbracoContextFactory.EnsureUmbracoContext();
// Executes after the standard ConfigureServices method
builder.ConfigureTestServices(services =>
return url;
}
// Add a test auth scheme with a test auth handler to authn and assign the user
services.AddAuthentication(TestAuthHandler.TestAuthenticationScheme)
.AddScheme<AuthenticationSchemeOptions, TestAuthHandler>(TestAuthHandler.TestAuthenticationScheme, options => { }));
});
private IHostBuilder CreateHostBuilder()
{
var hostBuilder = Host.CreateDefaultBuilder()
.ConfigureUmbracoDefaults()
.ConfigureAppConfiguration((context, configBuilder) =>
Client = Factory.CreateClient(new WebApplicationFactoryClientOptions
{
context.HostingEnvironment = TestHelper.GetWebHostEnvironment();
configBuilder.Sources.Clear();
configBuilder.AddInMemoryCollection(InMemoryConfiguration);
configBuilder.AddConfiguration(GlobalSetupTeardown.TestConfiguration);
AllowAutoRedirect = false
});
Configuration = configBuilder.Build();
})
.ConfigureWebHost(builder =>
LinkGenerator = Factory.Services.GetRequiredService<LinkGenerator>();
}
/// <summary>
/// Prepare a url before using <see cref="Client"/>.
/// This returns the url but also sets the HttpContext.request into to use this url.
/// </summary>
/// <returns>The string URL of the controller action.</returns>
protected string PrepareApiControllerUrl<T>(Expression<Func<T, object>> methodSelector)
where T : UmbracoApiController
{
var url = LinkGenerator.GetUmbracoApiService(methodSelector);
return PrepareUrl(url);
}
/// <summary>
/// Prepare a url before using <see cref="Client"/>.
/// This returns the url but also sets the HttpContext.request into to use this url.
/// </summary>
/// <returns>The string URL of the controller action.</returns>
protected string PrepareSurfaceControllerUrl<T>(Expression<Func<T, object>> methodSelector)
where T : SurfaceController
{
var url = LinkGenerator.GetUmbracoSurfaceUrl(methodSelector);
return PrepareUrl(url);
}
/// <summary>
/// Prepare a url before using <see cref="Client"/>.
/// This returns the url but also sets the HttpContext.request into to use this url.
/// </summary>
/// <returns>The string URL of the controller action.</returns>
protected string PrepareUrl(string url)
{
IUmbracoContextFactory umbracoContextFactory = GetRequiredService<IUmbracoContextFactory>();
IHttpContextAccessor httpContextAccessor = GetRequiredService<IHttpContextAccessor>();
httpContextAccessor.HttpContext = new DefaultHttpContext
{
builder.ConfigureServices((context, services) =>
Request =
{
Scheme = "https",
Host = new HostString("localhost", 80),
Path = url,
QueryString = new QueryString(string.Empty)
}
};
umbracoContextFactory.EnsureUmbracoContext();
return url;
}
private IHostBuilder CreateHostBuilder()
{
IHostBuilder hostBuilder = Host.CreateDefaultBuilder()
.ConfigureUmbracoDefaults()
.ConfigureAppConfiguration((context, configBuilder) =>
{
context.HostingEnvironment = TestHelper.GetWebHostEnvironment();
configBuilder.Sources.Clear();
configBuilder.AddInMemoryCollection(InMemoryConfiguration);
configBuilder.AddConfiguration(GlobalSetupTeardown.TestConfiguration);
ConfigureServices(services);
ConfigureTestServices(services);
services.AddUnique(CreateLoggerFactory());
if (!TestOptions.Boot)
Configuration = configBuilder.Build();
})
.ConfigureWebHost(builder =>
{
builder.ConfigureServices((context, services) =>
{
// If boot is false, we don't want the CoreRuntime hosted service to start
// So we replace it with a Mock
services.AddUnique(Mock.Of<IRuntime>());
}
context.HostingEnvironment = TestHelper.GetWebHostEnvironment();
ConfigureServices(services);
ConfigureTestServices(services);
services.AddUnique(CreateLoggerFactory());
if (!TestOptions.Boot)
{
// If boot is false, we don't want the CoreRuntime hosted service to start
// So we replace it with a Mock
services.AddUnique(Mock.Of<IRuntime>());
}
});
// call startup
builder.Configure(Configure);
})
.UseDefaultServiceProvider(cfg =>
{
// These default to true *if* WebHostEnvironment.EnvironmentName == Development
// When running tests, EnvironmentName used to be null on the mock that we register into services.
// Enable opt in for tests so that validation occurs regardless of environment name.
// Would be nice to have this on for UmbracoIntegrationTest also but requires a lot more effort to resolve issues.
cfg.ValidateOnBuild = true;
cfg.ValidateScopes = true;
});
// call startup
builder.Configure(Configure);
})
.UseDefaultServiceProvider(cfg =>
{
// These default to true *if* WebHostEnvironment.EnvironmentName == Development
// When running tests, EnvironmentName used to be null on the mock that we register into services.
// Enable opt in for tests so that validation occurs regardless of environment name.
// Would be nice to have this on for UmbracoIntegrationTest also but requires a lot more effort to resolve issues.
cfg.ValidateOnBuild = true;
cfg.ValidateScopes = true;
});
return hostBuilder;
}
return hostBuilder;
}
protected virtual IServiceProvider Services => Factory.Services;
protected virtual IServiceProvider Services => Factory.Services;
protected virtual T GetRequiredService<T>() => Factory.Services.GetRequiredService<T>();
protected virtual T GetRequiredService<T>() => Factory.Services.GetRequiredService<T>();
protected void ConfigureServices(IServiceCollection services)
{
services.AddTransient<TestUmbracoDatabaseFactoryProvider>();
protected void ConfigureServices(IServiceCollection services)
{
services.AddTransient<TestUmbracoDatabaseFactoryProvider>();
Core.Hosting.IHostingEnvironment hostingEnvironment = TestHelper.GetHostingEnvironment();
var hostingEnvironment = TestHelper.GetHostingEnvironment();
TypeLoader typeLoader = services.AddTypeLoader(
GetType().Assembly,
hostingEnvironment,
TestHelper.ConsoleLoggerFactory,
AppCaches.NoCache,
Configuration,
TestHelper.Profiler);
var typeLoader = services.AddTypeLoader(
GetType().Assembly,
hostingEnvironment,
TestHelper.ConsoleLoggerFactory,
AppCaches.NoCache,
Configuration,
TestHelper.Profiler);
services.AddLogger(TestHelper.GetWebHostEnvironment(), Configuration);
services.AddLogger(TestHelper.GetWebHostEnvironment(), Configuration);
var builder = new UmbracoBuilder(services, Configuration, typeLoader, TestHelper.ConsoleLoggerFactory, TestHelper.Profiler, AppCaches.NoCache, hostingEnvironment);
var builder = new UmbracoBuilder(services, Configuration, typeLoader, TestHelper.ConsoleLoggerFactory, TestHelper.Profiler, AppCaches.NoCache, hostingEnvironment);
builder
.AddConfiguration()
.AddUmbracoCore()
.AddWebComponents()
.AddNuCache()
.AddRuntimeMinifier()
.AddBackOfficeCore()
.AddBackOfficeAuthentication()
.AddBackOfficeIdentity()
.AddMembersIdentity()
.AddBackOfficeAuthorizationPolicies(TestAuthHandler.TestAuthenticationScheme)
.AddPreviewSupport()
.AddMvcAndRazor(mvcBuilding: mvcBuilder =>
{
// Adds Umbraco.Web.BackOffice
mvcBuilder.AddApplicationPart(typeof(ContentController).Assembly);
builder
.AddConfiguration()
.AddUmbracoCore()
.AddWebComponents()
.AddNuCache()
.AddRuntimeMinifier()
.AddBackOfficeCore()
.AddBackOfficeAuthentication()
.AddBackOfficeIdentity()
.AddMembersIdentity()
.AddBackOfficeAuthorizationPolicies(TestAuthHandler.TestAuthenticationScheme)
.AddPreviewSupport()
.AddMvcAndRazor(mvcBuilder =>
{
// Adds Umbraco.Web.BackOffice
mvcBuilder.AddApplicationPart(typeof(ContentController).Assembly);
// Adds Umbraco.Web.Common
mvcBuilder.AddApplicationPart(typeof(RenderController).Assembly);
// Adds Umbraco.Web.Common
mvcBuilder.AddApplicationPart(typeof(RenderController).Assembly);
// Adds Umbraco.Web.Website
mvcBuilder.AddApplicationPart(typeof(SurfaceController).Assembly);
// Adds Umbraco.Web.Website
mvcBuilder.AddApplicationPart(typeof(SurfaceController).Assembly);
// Adds Umbraco.Tests.Integration
mvcBuilder.AddApplicationPart(typeof(UmbracoTestServerTestBase).Assembly);
})
.AddWebServer()
.AddWebsite()
.AddUmbracoSqlServerSupport()
.AddUmbracoSqliteSupport()
.AddTestServices(TestHelper); // This is the important one!
// Adds Umbraco.Tests.Integration
mvcBuilder.AddApplicationPart(typeof(UmbracoTestServerTestBase).Assembly);
})
.AddWebServer()
.AddWebsite()
.AddUmbracoSqlServerSupport()
.AddUmbracoSqliteSupport()
.AddTestServices(TestHelper) // This is the important one!
.Build();
}
CustomTestSetup(builder);
builder.Build();
}
/// <summary>
/// Hook for registering test doubles.
/// </summary>
protected virtual void ConfigureTestServices(IServiceCollection services)
{
}
/// <summary>
/// Hook for registering test doubles.
/// </summary>
protected virtual void ConfigureTestServices(IServiceCollection services)
{
}
protected void Configure(IApplicationBuilder app)
{
UseTestDatabase(app);
protected void Configure(IApplicationBuilder app)
{
UseTestDatabase(app);
app.UseUmbraco()
.WithMiddleware(u =>
{
u.UseBackOffice();
u.UseWebsite();
})
.WithEndpoints(u =>
{
u.UseBackOfficeEndpoints();
u.UseWebsiteEndpoints();
});
app.UseUmbraco()
.WithMiddleware(u =>
{
u.UseBackOffice();
u.UseWebsite();
})
.WithEndpoints(u =>
{
u.UseBackOfficeEndpoints();
u.UseWebsiteEndpoints();
});
}
}
}

View File

@@ -0,0 +1,163 @@
using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using NUnit.Framework;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Serialization;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Tests.Common.Builders;
using Umbraco.Cms.Tests.Common.Builders.Extensions;
using Umbraco.Cms.Tests.Integration.TestServerTest;
using Umbraco.Cms.Web.BackOffice.Controllers;
using Umbraco.Cms.Web.Common.Formatters;
using Umbraco.Extensions;
namespace Umbraco.Cms.Tests.Integration.Umbraco.Web.BackOffice.Filters;
[TestFixture]
public class OutgoingEditorModelEventFilterTests : UmbracoTestServerTestBase
{
private static int _messageCount;
private static Action<SendingContentNotification> _handler;
protected override void CustomTestSetup(IUmbracoBuilder builder)
{
builder.AddNotificationHandler<SendingContentNotification, FilterEventHandler>();
}
[TearDown]
public void Reset() => ResetNotifications();
[Test]
public async Task Content_Item_With_Schedule_Raises_SendingContentNotification()
{
IContentTypeService contentTypeService = GetRequiredService<IContentTypeService>();
IContentService contentService = GetRequiredService<IContentService>();
IJsonSerializer serializer = GetRequiredService<IJsonSerializer>();
var contentType = new ContentTypeBuilder().Build();
contentTypeService.Save(contentType);
var contentToRequest = new ContentBuilder()
.WithoutIdentity()
.WithContentType(contentType)
.Build();
contentService.Save(contentToRequest);
_handler = notification => notification.Content.AllowPreview = false;
var url = PrepareApiControllerUrl<ContentController>(x => x.GetById(contentToRequest.Id));
HttpResponseMessage response = await Client.GetAsync(url);
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
var text = await response.Content.ReadAsStringAsync();
text = text.TrimStart(AngularJsonMediaTypeFormatter.XsrfPrefix);
var display = serializer.Deserialize<ContentItemDisplayWithSchedule>(text);
Assert.AreEqual(1, _messageCount);
Assert.IsNotNull(display);
Assert.IsFalse(display.AllowPreview);
}
[Test]
public async Task Publish_Schedule_Is_Mapped_Correctly()
{
const string UsIso = "en-US";
const string DkIso = "da-DK";
const string SweIso = "sv-SE";
var contentTypeService = GetRequiredService<IContentTypeService>();
var contentService = GetRequiredService<IContentService>();
var localizationService = GetRequiredService<ILocalizationService>();
IJsonSerializer serializer = GetRequiredService<IJsonSerializer>();
var contentType = new ContentTypeBuilder()
.WithContentVariation(ContentVariation.Culture)
.Build();
contentTypeService.Save(contentType);
var dkLang = new LanguageBuilder()
.WithCultureInfo(DkIso)
.WithIsDefault(false)
.Build();
var sweLang = new LanguageBuilder()
.WithCultureInfo(SweIso)
.WithIsDefault(false)
.Build();
localizationService.Save(dkLang);
localizationService.Save(sweLang);
var content = new ContentBuilder()
.WithoutIdentity()
.WithContentType(contentType)
.WithCultureName(UsIso, "Same Name")
.WithCultureName(SweIso, "Same Name")
.WithCultureName(DkIso, "Same Name")
.Build();
contentService.Save(content);
var schedule = new ContentScheduleCollection();
var dkReleaseDate = new DateTime(2022, 06, 22, 21, 30, 42);
var dkExpireDate = new DateTime(2022, 07, 15, 18, 00, 00);
var sweReleaseDate = new DateTime(2022, 06, 23, 22, 30, 42);
var sweExpireDate = new DateTime(2022, 07, 10, 14, 20, 00);
schedule.Add(DkIso, dkReleaseDate, dkExpireDate);
schedule.Add(SweIso, sweReleaseDate, sweExpireDate);
contentService.PersistContentSchedule(content, schedule);
var url = PrepareApiControllerUrl<ContentController>(x => x.GetById(content.Id));
HttpResponseMessage response = await Client.GetAsync(url);
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
var text = await response.Content.ReadAsStringAsync();
text = text.TrimStart(AngularJsonMediaTypeFormatter.XsrfPrefix);
var display = serializer.Deserialize<ContentItemDisplayWithSchedule>(text);
Assert.IsNotNull(display);
Assert.AreEqual(1, _messageCount);
var dkVariant = display.Variants.FirstOrDefault(x => x.Language?.IsoCode == DkIso);
Assert.IsNotNull(dkVariant);
Assert.AreEqual(dkReleaseDate, dkVariant.ReleaseDate);
Assert.AreEqual(dkExpireDate, dkVariant.ExpireDate);
var sweVariant = display.Variants.FirstOrDefault(x => x.Language?.IsoCode == SweIso);
Assert.IsNotNull(sweVariant);
Assert.AreEqual(sweReleaseDate, sweVariant.ReleaseDate);
Assert.AreEqual(sweExpireDate, sweVariant.ExpireDate);
var usVariant = display.Variants.FirstOrDefault(x => x.Language?.IsoCode == UsIso);
Assert.IsNotNull(usVariant);
Assert.IsNull(usVariant.ReleaseDate);
Assert.IsNull(usVariant.ExpireDate);
}
private void ResetNotifications()
{
_messageCount = 0;
_handler = null;
}
private class FilterEventHandler : INotificationHandler<SendingContentNotification>
{
public void Handle(SendingContentNotification notification)
{
_messageCount += 1;
_handler?.Invoke(notification);
}
}
}

View File

@@ -71,7 +71,7 @@ public class ConfigurationExtensionsTests
{
const string ConfiguredConnectionString =
"Data Source=|DataDirectory|/Umbraco.sqlite.db;Cache=Shared;Foreign Keys=True;Pooling=True";
const string ConfiguredProviderName = "Microsoft.Data.SQLite";
const string ConfiguredProviderName = "Microsoft.Data.Sqlite";
var mockedConfig = CreateConfig(ConfiguredConnectionString, ConfiguredProviderName);
SetDataDirectory();
@@ -80,7 +80,7 @@ public class ConfigurationExtensionsTests
AssertResults(
@"Data Source=C:\Data/Umbraco.sqlite.db;Cache=Shared;Foreign Keys=True;Pooling=True",
"Microsoft.Data.SQLite",
"Microsoft.Data.Sqlite",
connectionString,
providerName);
}

View File

@@ -592,10 +592,11 @@ namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Infrastructure.Scoping
using (var scope = scopeProvider.CreateScope())
{
Assert.AreEqual(0, scope.Depth);
Assert.AreEqual(0,scope.Depth);
}
}
[Test]
public void Depth_WhenChildScope_ReturnsDepth()
{