Cover the configuration change publishing filter with its test

The Castle Siege persistence import (#860) brought
EntityFrameworkContextBase.PublishesConfigurationChanges into the tree,
but not the test which pins its behaviour, and not the guard which keeps
the two initialization test fixtures from configuring the connection
twice.

Add both, unchanged from upstream.
This commit is contained in:
Acentech Dev
2026-08-13 08:50:53 +03:00
parent 52950362ff
commit 790a101f23
2 changed files with 38 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
// <copyright file="ConfigurationChangePublishingTests.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>
namespace MUnique.OpenMU.Persistence.Initialization.Tests;
using MUnique.OpenMU.Persistence.EntityFramework;
using MUnique.OpenMU.Persistence.EntityFramework.Model;
/// <summary>
/// Tests filtering of Entity Framework configuration change notifications.
/// </summary>
[TestFixture]
internal class ConfigurationChangePublishingTests
{
/// <summary>
/// Verifies that only configuration entities are published to the configuration change listener.
/// </summary>
/// <param name="entityType">The entity type.</param>
/// <param name="shouldPublish">Whether changes of this entity type should be published.</param>
[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));
}
}

View File

@@ -24,7 +24,10 @@ internal class JsonQueryBuilderTests
[OneTimeSetUp]
public void Setup()
{
ConnectionConfigurator.Initialize(new ConfigFileDatabaseConnectionStringProvider());
if (!ConnectionConfigurator.IsInitialized)
{
ConnectionConfigurator.Initialize(new ConfigFileDatabaseConnectionStringProvider());
}
}
/// <summary>