diff --git a/tests/MUnique.OpenMU.Persistence.Initialization.Tests/ConfigurationChangePublishingTests.cs b/tests/MUnique.OpenMU.Persistence.Initialization.Tests/ConfigurationChangePublishingTests.cs new file mode 100644 index 0000000..cfbb9c3 --- /dev/null +++ b/tests/MUnique.OpenMU.Persistence.Initialization.Tests/ConfigurationChangePublishingTests.cs @@ -0,0 +1,34 @@ +// +// Licensed under the MIT License. See LICENSE file in the project root for full license information. +// + +namespace MUnique.OpenMU.Persistence.Initialization.Tests; + +using MUnique.OpenMU.Persistence.EntityFramework; +using MUnique.OpenMU.Persistence.EntityFramework.Model; + +/// +/// Tests filtering of Entity Framework configuration change notifications. +/// +[TestFixture] +internal class ConfigurationChangePublishingTests +{ + /// + /// Verifies that only configuration entities are published to the configuration change listener. + /// + /// The entity type. + /// Whether changes of this entity type should be published. + [TestCase(typeof(CastleSiegeConfiguration), true)] + [TestCase(typeof(CastleSiegeNpcState), false)] + [TestCase(typeof(Account), false)] + [TestCase(typeof(Guild), false)] + [TestCase(typeof(Friend), false)] + public void OnlyConfigurationEntitiesArePublished(Type entityType, bool shouldPublish) + { + using var context = new EntityDataContext(); + var modelType = context.Model.FindEntityType(entityType); + + Assert.That(modelType, Is.Not.Null); + Assert.That(EntityFrameworkContextBase.PublishesConfigurationChanges(modelType!), Is.EqualTo(shouldPublish)); + } +} diff --git a/tests/MUnique.OpenMU.Persistence.Initialization.Tests/JsonQueryBuilderTests.cs b/tests/MUnique.OpenMU.Persistence.Initialization.Tests/JsonQueryBuilderTests.cs index c320853..5dfdd0f 100644 --- a/tests/MUnique.OpenMU.Persistence.Initialization.Tests/JsonQueryBuilderTests.cs +++ b/tests/MUnique.OpenMU.Persistence.Initialization.Tests/JsonQueryBuilderTests.cs @@ -24,7 +24,10 @@ internal class JsonQueryBuilderTests [OneTimeSetUp] public void Setup() { - ConnectionConfigurator.Initialize(new ConfigFileDatabaseConnectionStringProvider()); + if (!ConnectionConfigurator.IsInitialized) + { + ConnectionConfigurator.Initialize(new ConfigFileDatabaseConnectionStringProvider()); + } } ///