elsa-core/test/integration/Elsa.Core.IntegrationTests/Autofixture/WithMongoDbAttribute.cs
Craig Fowler 8379d4a70c Complete refactoring for composable attributes
This takes the work begun in
  d285b8b505
and completes it for all other attributes/usages.
2021-04-02 11:41:06 +01:00

29 lines
930 B
C#

using System;
using Elsa.Persistence.MongoDb.Extensions;
using Elsa.Testing.Shared.AutoFixture.Attributes;
using Elsa.Testing.Shared.Helpers;
namespace Elsa.Core.IntegrationTests.Autofixture
{
public class WithMongoDbAttribute : ElsaHostBuilderBuilderCustomizeAttributeBase
{
readonly string dbName;
public override Action<ElsaHostBuilderBuilder> GetBuilderCustomizer()
{
return builder => {
builder.ElsaCallbacks.Add(elsa => {
elsa.UseMongoDbPersistence(opts => {
opts.ConnectionString = "mongodb://localhost:27017";
opts.DatabaseName = dbName;
});
});
};
}
public WithMongoDbAttribute(string dbName = "IntegrationTests")
{
this.dbName = dbName ?? throw new ArgumentNullException(nameof(dbName));
}
}
}