-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMultipleRegistrationTests.cs
More file actions
54 lines (47 loc) · 1.75 KB
/
Copy pathMultipleRegistrationTests.cs
File metadata and controls
54 lines (47 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using Cleipnir.ResilientFunctions.Storage;
using Cleipnir.ResilientFunctions.Domain;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
namespace Cleipnir.Flows.Tests.Flows;
[TestClass]
public class MultipleRegistrationTests
{
[TestMethod]
public void SameFlowTypeWithSameNameCanBeRegisteredSeveralTimes()
{
var serviceCollection = new ServiceCollection();
var store = new InMemoryFunctionStore();
var flowsContainer = new FlowsContainer(store, serviceCollection.BuildServiceProvider());
_ = new TestFlowType1s(flowsContainer);
_ = new TestFlowType1s(flowsContainer);
}
[TestMethod]
public void DifferentFlowTypesWithSameNameCannotBeRegisteredSeveralTimes()
{
var serviceCollection = new ServiceCollection();
var store = new InMemoryFunctionStore();
var flowsContainer = new FlowsContainer(store, serviceCollection.BuildServiceProvider());
_ = new TestFlowType1s(flowsContainer);
Should.Throw<InvalidOperationException>(() =>
new TestFlowType2s(flowsContainer)
);
}
private class TestFlowType1 : Flow
{
public override Task Run() => Task.CompletedTask;
}
private class TestFlowType1s : Flows<TestFlowType1>
{
public TestFlowType1s(FlowsContainer flowsContainer, FlowOptions? options = null)
: base("TestFlow", flowsContainer, options) { }
}
private class TestFlowType2 : Flow
{
public override Task Run() => Task.CompletedTask;
}
private class TestFlowType2s : Flows<TestFlowType2>
{
public TestFlowType2s(FlowsContainer flowsContainer, FlowOptions? options = null)
: base("TestFlow", flowsContainer, options) { }
}
}