File tree Expand file tree Collapse file tree 5 files changed +94
-2
lines changed
WorkflowCore.IntegrationTests/Scenarios
SingleNodeLockProviderTests Expand file tree Collapse file tree 5 files changed +94
-2
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ protected override void ConfigureWorkflow(IServiceCollection services)
64
64
counter ++ ;
65
65
}
66
66
67
+ Host . PublishEvent ( "MyEvent" , "1" , "Fail" ) ;
67
68
Host . PublishEvent ( "MyEvent" , "0" , "Pass" ) ;
68
69
69
70
Instance = PersistenceProvider . GetWorkflowInstance ( WorkflowId ) . Result ;
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Collections . Generic ;
3
+ using System . Text ;
4
+ using WorkflowCore . Interface ;
5
+ using NUnit ;
6
+ using FluentAssertions ;
7
+ using NUnit . Framework ;
8
+
9
+ namespace WorkflowCore . TestAssets . LockProvider
10
+ {
11
+ public abstract class DistributedLockProviderTests
12
+ {
13
+ protected IDistributedLockProvider Subject ;
14
+
15
+ [ SetUp ]
16
+ public void Setup ( )
17
+ {
18
+ Subject = CreateProvider ( ) ;
19
+ Subject . Start ( ) ;
20
+ }
21
+
22
+ protected abstract IDistributedLockProvider CreateProvider ( ) ;
23
+
24
+ [ Test ]
25
+ public async void AcquiresLock ( )
26
+ {
27
+ const string lock1 = "lock1" ;
28
+ const string lock2 = "lock2" ;
29
+ await Subject . AcquireLock ( lock2 ) ;
30
+
31
+ var acquired = await Subject . AcquireLock ( lock1 ) ;
32
+
33
+ acquired . Should ( ) . Be ( true ) ;
34
+ }
35
+
36
+ [ Test ]
37
+ public async void DoesNotAcquireWhenLocked ( )
38
+ {
39
+ const string lock1 = "lock1" ;
40
+ await Subject . AcquireLock ( lock1 ) ;
41
+
42
+ var acquired = await Subject . AcquireLock ( lock1 ) ;
43
+
44
+ acquired . Should ( ) . Be ( false ) ;
45
+ }
46
+
47
+ [ Test ]
48
+ public async void ReleasesLock ( )
49
+ {
50
+ const string lock1 = "lock1" ;
51
+ await Subject . AcquireLock ( lock1 ) ;
52
+
53
+ await Subject . ReleaseLock ( lock1 ) ;
54
+
55
+ var available = await Subject . AcquireLock ( lock1 ) ;
56
+ available . Should ( ) . Be ( true ) ;
57
+ }
58
+
59
+ [ TearDown ]
60
+ public virtual void TearDown ( )
61
+ {
62
+ Subject . Stop ( ) ;
63
+ }
64
+ }
65
+ }
Original file line number Diff line number Diff line change 17
17
18
18
<ItemGroup >
19
19
<PackageReference Include =" FluentAssertions" Version =" 4.19.0" />
20
- <PackageReference Include =" Machine.Fakes" Version =" 2.8.0-beta3 " />
21
- <PackageReference Include =" Machine.Fakes.Moq" Version =" 2.8.0-beta3 " />
20
+ <PackageReference Include =" Machine.Fakes" Version =" 2.8.0" />
21
+ <PackageReference Include =" Machine.Fakes.Moq" Version =" 2.8.0" />
22
22
<PackageReference Include =" Machine.Specifications" Version =" 0.11.0" />
23
23
<PackageReference Include =" Machine.Specifications.Should" Version =" 0.11.0" />
24
24
<PackageReference Include =" Moq" Version =" 4.7.1" />
25
25
<PackageReference Include =" Newtonsoft.Json" Version =" 9.0.1" />
26
+ <PackageReference Include =" NUnit" Version =" 3.6.1" />
26
27
</ItemGroup >
27
28
28
29
</Project >
Original file line number Diff line number Diff line change
1
+ using FluentAssertions ;
2
+ using NUnit . Framework ;
3
+ using System ;
4
+ using System . Collections . Generic ;
5
+ using System . Text ;
6
+ using WorkflowCore . Interface ;
7
+ using WorkflowCore . Services ;
8
+ using WorkflowCore . TestAssets . LockProvider ;
9
+
10
+ namespace WorkflowCore . UnitTests . SingleNodeLockProviderTests
11
+ {
12
+ [ TestFixture ]
13
+ public class SingleNodeLockProviderTests : DistributedLockProviderTests
14
+ {
15
+ protected override IDistributedLockProvider CreateProvider ( )
16
+ {
17
+ return new SingleNodeLockProvider ( ) ;
18
+ }
19
+ }
20
+ }
Original file line number Diff line number Diff line change 30
30
<PackageReference Include =" Microsoft.Extensions.Logging.Console" Version =" 1.1.1" />
31
31
<PackageReference Include =" Microsoft.Extensions.Logging.Debug" Version =" 1.1.1" />
32
32
<PackageReference Include =" Moq" Version =" 4.7.1" />
33
+ <PackageReference Include =" NUnit" Version =" 3.6.1" />
34
+ <PackageReference Include =" NUnit.ConsoleRunner" Version =" 3.6.1" />
35
+ <PackageReference Include =" NUnit3TestAdapter" Version =" 3.7.0" />
36
+ <PackageReference Include =" System.Runtime.InteropServices" Version =" 4.3.0" />
37
+ <DotNetCliToolReference Include =" dotnet-xunit" Version =" 2.3.0-beta1-build3642" />
33
38
</ItemGroup >
34
39
35
40
</Project >
You can’t perform that action at this time.
0 commit comments