From 8bf5a24fbc40e01ebc8fd56bc7d17557cfd1168e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mehmet=20Tu=CC=88ken?= Date: Wed, 18 Dec 2019 03:14:34 +0300 Subject: [PATCH] [modules/docs] fix mongo.exe dispose --- .../Volo/Docs/MongoDB/DocsMongoDBTestModule.cs | 6 +----- .../Volo/Docs/MongoDB/MongoDbFixture.cs | 16 ++++++++++++++++ .../Volo/Docs/MongoDB/MongoTestCollection.cs | 10 ++++++++++ .../Volo/Docs/Project/ProjectRepository_Tests.cs | 2 ++ 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/MongoDB/MongoDbFixture.cs create mode 100644 modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/MongoDB/MongoTestCollection.cs diff --git a/modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/MongoDB/DocsMongoDBTestModule.cs b/modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/MongoDB/DocsMongoDBTestModule.cs index c5fef83ddb..b31f9b5acd 100644 --- a/modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/MongoDB/DocsMongoDBTestModule.cs +++ b/modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/MongoDB/DocsMongoDBTestModule.cs @@ -1,6 +1,4 @@ using System; -using Mongo2Go; -using Volo.Abp; using Volo.Abp.Data; using Volo.Abp.Modularity; @@ -12,11 +10,9 @@ namespace Volo.Docs.MongoDB )] public class DocsMongoDBTestModule : AbpModule { - private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start(); - public override void ConfigureServices(ServiceConfigurationContext context) { - var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') + + var connectionString = MongoDbFixture.ConnectionString.EnsureEndsWith('/') + "Db_" + Guid.NewGuid().ToString("N"); diff --git a/modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/MongoDB/MongoDbFixture.cs b/modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/MongoDB/MongoDbFixture.cs new file mode 100644 index 0000000000..fc920813ab --- /dev/null +++ b/modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/MongoDB/MongoDbFixture.cs @@ -0,0 +1,16 @@ +using System; +using Mongo2Go; + +namespace Volo.Docs.MongoDB +{ + public class MongoDbFixture : IDisposable + { + private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start(); + public static readonly string ConnectionString = MongoDbRunner.ConnectionString; + + public void Dispose() + { + MongoDbRunner?.Dispose(); + } + } +} \ No newline at end of file diff --git a/modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/MongoDB/MongoTestCollection.cs b/modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/MongoDB/MongoTestCollection.cs new file mode 100644 index 0000000000..86505c5a73 --- /dev/null +++ b/modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/MongoDB/MongoTestCollection.cs @@ -0,0 +1,10 @@ +using Xunit; + +namespace Volo.Docs.MongoDB +{ + [CollectionDefinition(Name)] + public class MongoTestCollection : ICollectionFixture + { + public const string Name = "MongoDB Collection"; + } +} \ No newline at end of file diff --git a/modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/Project/ProjectRepository_Tests.cs b/modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/Project/ProjectRepository_Tests.cs index 6f2df01a11..696dd31185 100644 --- a/modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/Project/ProjectRepository_Tests.cs +++ b/modules/docs/test/Volo.Docs.MongoDB.Tests/Volo/Docs/Project/ProjectRepository_Tests.cs @@ -1,7 +1,9 @@ using Volo.Docs.MongoDB; +using Xunit; namespace Volo.Docs.Project { + [Collection(MongoTestCollection.Name)] public class ProjectRepository_Tests : ProjectRepository_Tests { }