Browse Source

Updated mongodb test project

ipaddr
Galip Tolga Erdem 5 years ago
parent
commit
e16dd600fe
  1. 10
      services/catalog/test/EShopOnAbp.CatalogService.Domain.Tests/CatalogServiceDomainCollection.cs
  2. 4
      services/catalog/test/EShopOnAbp.CatalogService.Domain.Tests/CatalogServiceDomainTestModule.cs
  3. 2
      services/catalog/test/EShopOnAbp.CatalogService.Domain.Tests/EShopOnAbp.CatalogService.Domain.Tests.csproj
  4. 17
      services/catalog/test/EShopOnAbp.CatalogService.MongoDB.Tests/EShopOnAbp.CatalogService.MongoDB.Tests.csproj
  5. 9
      services/catalog/test/EShopOnAbp.CatalogService.MongoDB.Tests/MongoDB/CatalogServiceMongoCollection.cs
  6. 8
      services/catalog/test/EShopOnAbp.CatalogService.MongoDB.Tests/MongoDB/CatalogServiceMongoDbCollectionFixtureBase.cs
  7. 22
      services/catalog/test/EShopOnAbp.CatalogService.MongoDB.Tests/MongoDB/CatalogServiceMongoDbFixture.cs
  8. 10
      services/catalog/test/EShopOnAbp.CatalogService.MongoDB.Tests/MongoDB/CatalogServiceMongoDbTestBase.cs
  9. 27
      services/catalog/test/EShopOnAbp.CatalogService.MongoDB.Tests/MongoDB/CatalogServiceMongoDbTestModule.cs
  10. 6
      services/catalog/test/EShopOnAbp.CatalogService.TestBase/CatalogServiceTestConsts.cs

10
services/catalog/test/EShopOnAbp.CatalogService.Domain.Tests/CatalogServiceDomainCollection.cs

@ -0,0 +1,10 @@
using EShopOnAbp.CatalogService.MongoDB;
using Xunit;
namespace EShopOnAbp.CatalogService;
[CollectionDefinition(CatalogServiceTestConsts.CollectionDefinitionName)]
public class CatalogServiceDomainCollection : CatalogServiceMongoDbCollectionFixtureBase
{
}

4
services/catalog/test/EShopOnAbp.CatalogService.Domain.Tests/CatalogServiceDomainTestModule.cs

@ -1,10 +1,10 @@
using EShopOnAbp.CatalogService.EntityFrameworkCore;
using EShopOnAbp.CatalogService.MongoDB;
using Volo.Abp.Modularity;
namespace EShopOnAbp.CatalogService
{
[DependsOn(
typeof(CatalogServiceEntityFrameworkCoreTestModule)
typeof(CatalogServiceMongoDbTestModule)
)]
public class CatalogServiceDomainTestModule : AbpModule
{

2
services/catalog/test/EShopOnAbp.CatalogService.Domain.Tests/EShopOnAbp.CatalogService.Domain.Tests.csproj

@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\EShopOnAbp.CatalogService.EntityFrameworkCore.Tests\EShopOnAbp.CatalogService.EntityFrameworkCore.Tests.csproj" />
<ProjectReference Include="..\EShopOnAbp.CatalogService.MongoDB.Tests\EShopOnAbp.CatalogService.MongoDB.Tests.csproj" />
</ItemGroup>
<ItemGroup>

17
services/catalog/test/EShopOnAbp.CatalogService.MongoDB.Tests/EShopOnAbp.CatalogService.MongoDB.Tests.csproj

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>EShopOnAbp.CatalogService</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Mongo2Go" Version="3.1.3" />
<ProjectReference Include="..\..\src\EShopOnAbp.CatalogService.MongoDB\EShopOnAbp.CatalogService.MongoDB.csproj" />
<ProjectReference Include="..\EShopOnAbp.CatalogService.TestBase\EShopOnAbp.CatalogService.TestBase.csproj" />
</ItemGroup>
</Project>

9
services/catalog/test/EShopOnAbp.CatalogService.MongoDB.Tests/MongoDB/CatalogServiceMongoCollection.cs

@ -0,0 +1,9 @@
using Xunit;
namespace EShopOnAbp.CatalogService.MongoDB;
[CollectionDefinition(CatalogServiceTestConsts.CollectionDefinitionName)]
public class CatalogServiceMongoCollection : CatalogServiceMongoDbCollectionFixtureBase
{
}

8
services/catalog/test/EShopOnAbp.CatalogService.MongoDB.Tests/MongoDB/CatalogServiceMongoDbCollectionFixtureBase.cs

@ -0,0 +1,8 @@
using Xunit;
namespace EShopOnAbp.CatalogService.MongoDB;
public class CatalogServiceMongoDbCollectionFixtureBase : ICollectionFixture<CatalogServiceMongoDbFixture>
{
}

22
services/catalog/test/EShopOnAbp.CatalogService.MongoDB.Tests/MongoDB/CatalogServiceMongoDbFixture.cs

@ -0,0 +1,22 @@
using System;
using Mongo2Go;
namespace EShopOnAbp.CatalogService.MongoDB
{
public class CatalogServiceMongoDbFixture : IDisposable
{
private static readonly MongoDbRunner MongoDbRunner;
public static readonly string ConnectionString;
static CatalogServiceMongoDbFixture()
{
MongoDbRunner = MongoDbRunner.Start(singleNodeReplSet: true, singleNodeReplSetWaitTimeout: 20);
ConnectionString = MongoDbRunner.ConnectionString;
}
public void Dispose()
{
MongoDbRunner?.Dispose();
}
}
}

10
services/catalog/test/EShopOnAbp.CatalogService.MongoDB.Tests/MongoDB/CatalogServiceMongoDbTestBase.cs

@ -0,0 +1,10 @@
namespace EShopOnAbp.CatalogService.MongoDB
{
/* This class can be used as a base class for MongoDB integration tests,
* while SampleRepository_Tests uses a different approach.
*/
public abstract class CatalogServiceMongoDbTestBase : CatalogServiceTestBase<CatalogServiceMongoDbTestModule>
{
}
}

27
services/catalog/test/EShopOnAbp.CatalogService.MongoDB.Tests/MongoDB/CatalogServiceMongoDbTestModule.cs

@ -0,0 +1,27 @@
using System;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
using Volo.Abp.Uow;
namespace EShopOnAbp.CatalogService.MongoDB
{
[DependsOn(
typeof(CatalogServiceTestBaseModule),
typeof(CatalogServiceMongoDbModule)
)]
public class CatalogServiceMongoDbTestModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var stringArray = CatalogServiceMongoDbFixture.ConnectionString.Split('?');
var connectionString = stringArray[0].EnsureEndsWith('/') +
"Db_" +
Guid.NewGuid().ToString("N") + "/?" + stringArray[1];
Configure<AbpDbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = connectionString;
});
}
}
}

6
services/catalog/test/EShopOnAbp.CatalogService.TestBase/CatalogServiceTestConsts.cs

@ -0,0 +1,6 @@
namespace EShopOnAbp.CatalogService;
public static class CatalogServiceTestConsts
{
public const string CollectionDefinitionName = "CatalogService collection";
}
Loading…
Cancel
Save