2022-03-25 08:58:07 +01:00
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
using Moq;
|
2018-06-29 19:52:40 +02:00
|
|
|
using NUnit.Framework;
|
2021-02-09 10:22:42 +01:00
|
|
|
using Umbraco.Cms.Core.Configuration;
|
2022-03-25 08:58:07 +01:00
|
|
|
using Umbraco.Cms.Core.Configuration.Models;
|
2021-04-16 11:37:01 +02:00
|
|
|
using Umbraco.Cms.Core.Events;
|
2021-02-12 12:40:08 +01:00
|
|
|
using Umbraco.Cms.Infrastructure.Migrations.Install;
|
2021-02-10 14:45:44 +01:00
|
|
|
using Umbraco.Cms.Tests.Common.Testing;
|
2021-02-11 08:30:27 +01:00
|
|
|
using Umbraco.Cms.Tests.Integration.Testing;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
2021-02-11 08:30:27 +01:00
|
|
|
namespace Umbraco.Cms.Tests.Integration.Umbraco.Infrastructure.Persistence
|
2018-06-29 19:52:40 +02:00
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
|
2021-01-11 09:04:05 +01:00
|
|
|
public class SchemaValidationTest : UmbracoIntegrationTest
|
2018-06-29 19:52:40 +02:00
|
|
|
{
|
2021-01-11 09:04:05 +01:00
|
|
|
private IUmbracoVersion UmbracoVersion => GetRequiredService<IUmbracoVersion>();
|
2021-04-16 11:37:01 +02:00
|
|
|
private IEventAggregator EventAggregator => GetRequiredService<IEventAggregator>();
|
2021-01-11 09:04:05 +01:00
|
|
|
|
2018-06-29 19:52:40 +02:00
|
|
|
[Test]
|
|
|
|
|
public void DatabaseSchemaCreation_Produces_DatabaseSchemaResult_With_Zero_Errors()
|
|
|
|
|
{
|
|
|
|
|
DatabaseSchemaResult result;
|
|
|
|
|
|
|
|
|
|
using (var scope = ScopeProvider.CreateScope())
|
|
|
|
|
{
|
2022-03-25 08:58:07 +01:00
|
|
|
var schema = new DatabaseSchemaCreator(scope.Database, LoggerFactory.CreateLogger<DatabaseSchemaCreator>(), LoggerFactory, UmbracoVersion, EventAggregator, Mock.Of<IOptionsMonitor<InstallDefaultDataSettings>>(x => x.CurrentValue == new InstallDefaultDataSettings()));
|
2021-01-11 09:04:05 +01:00
|
|
|
result = schema.ValidateSchema(DatabaseSchemaCreator.OrderedTables);
|
2018-06-29 19:52:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Assert
|
|
|
|
|
Assert.That(result.Errors.Count, Is.EqualTo(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|