Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:

# Install .NET Core
- name: Install .NET ${{ matrix.dotnet-version }}
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.os == 'ubuntu-22.04' }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
Expand Down
2 changes: 1 addition & 1 deletion src/Dependency.Versions.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Xunit>2.4.1</Xunit>
<Xunit>1.1.0</Xunit>
<DotNetWatcher>1.0.1</DotNetWatcher>
<NewtonsoftJson>12.0.2</NewtonsoftJson>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit.runner.console" Version="2.9.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit.v3" Version="1.1.0" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void validation_throws_on_mising_stream()
new PrefixedCamelCaseStreamNameBuilder(),
_eventSerializer);
listener.EventStream.Subscribe(new AdHocHandler<Event>(Handle));
Assert.Throws<ArgumentException>(() => listener.Start(missingStream, validateStream: true));
Assert.Throws<ArgumentException>(() => listener.Start(missingStream, validateStream: true, cancelWaitToken: TestContext.Current.CancellationToken));
listener.Dispose();
}
[Fact]
Expand All @@ -55,7 +55,7 @@ public void can_subscribe_to_missing_stream()
new PrefixedCamelCaseStreamNameBuilder(),
_eventSerializer);
listener.EventStream.Subscribe(new AdHocHandler<Event>(Handle));
listener.Start(missingStream, validateStream: false);
listener.Start(missingStream, validateStream: false, cancelWaitToken: TestContext.Current.CancellationToken);
Assert.True(listener.IsLive);
listener.Dispose();
}
Expand Down
32 changes: 16 additions & 16 deletions src/ReactiveDomain.Foundation.Tests/when_using_read_model_base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void can_start_streams_by_aggregate()
var aggId = Guid.NewGuid();
var s1 = Namer.GenerateForAggregate(typeof(TestAggregate), aggId);
AppendEvents(1, _conn, s1, 7);
Start<TestAggregate>(aggId);
Start<TestAggregate>(aggId, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.AtLeastModelVersion(this, 2, msg: $"Expected 2 got {Version}"); // 1 message + CatchupSubscriptionBecameLive
AssertEx.IsOrBecomesTrue(() => Sum == 7);
}
Expand All @@ -73,15 +73,15 @@ public void can_start_streams_by_aggregate_category()
AppendEvents(1, _conn, s1, 7);
var s2 = Namer.GenerateForAggregate(typeof(ReadModelTestCategoryAggregate), Guid.NewGuid());
AppendEvents(1, _conn, s2, 5);
Start<ReadModelTestCategoryAggregate>(null, true);
Start<ReadModelTestCategoryAggregate>(null, true, cancelWaitToken: TestContext.Current.CancellationToken);

AssertEx.AtLeastModelVersion(this, 3, msg: $"Expected 3 got {Version}");
AssertEx.IsOrBecomesTrue(() => Sum == 12);
}
[Fact]
public void can_read_one_stream()
{
Start(_stream1);
Start(_stream1, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.AtLeastModelVersion(this, 11, msg: $"Expected 11 got {Version}");
AssertEx.IsOrBecomesTrue(() => Sum == 20);
//confirm checkpoints
Expand All @@ -91,8 +91,8 @@ public void can_read_one_stream()
[Fact]
public void can_read_two_streams()
{
Start(_stream1);
Start(_stream2);
Start(_stream1, cancelWaitToken: TestContext.Current.CancellationToken);
Start(_stream2, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.AtLeastModelVersion(this, 22, msg: $"Expected 22 got {Version}");
AssertEx.IsOrBecomesTrue(() => Sum == 50);
//confirm checkpoints
Expand All @@ -104,25 +104,25 @@ public void can_read_two_streams()
[Fact]
public void can_wait_for_one_stream_to_go_live()
{
Start(_stream1, null, true);
Start(_stream1, null, true, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.AtLeastModelVersion(this, 11, TimeSpan.FromMilliseconds(100), msg: $"Expected 11 got {Version}");
AssertEx.IsOrBecomesTrue(() => Sum == 20, 100);
}
[Fact]
public void can_wait_for_two_streams_to_go_live()
{
Start(_stream1, null, true);
Start(_stream1, null, true, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.AtLeastModelVersion(this, 11, TimeSpan.FromMilliseconds(100), msg: $"Expected 11 got {Version}");
AssertEx.IsOrBecomesTrue(() => Sum == 20, 150);

Start(_stream2, null, true);
Start(_stream2, null, true, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.AtLeastModelVersion(this, 21, TimeSpan.FromMilliseconds(100), msg: $"Expected 21 got {Version}");
AssertEx.IsOrBecomesTrue(() => Sum == 50, 150);
}
[Fact]
public void can_listen_to_one_stream()
{
Start(_stream1);
Start(_stream1, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.AtLeastModelVersion(this, 11, msg: $"Expected 11 got {Version}");
AssertEx.IsOrBecomesTrue(() => Sum == 20);
//add more messages
Expand All @@ -137,8 +137,8 @@ public void can_listen_to_one_stream()
[Fact]
public void can_listen_to_two_streams()
{
Start(_stream1);
Start(_stream2);
Start(_stream1, cancelWaitToken: TestContext.Current.CancellationToken);
Start(_stream2, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.AtLeastModelVersion(this, 22, msg: $"Expected 22 got {Version}");
AssertEx.IsOrBecomesTrue(() => Sum == 50);
//add more messages
Expand All @@ -159,7 +159,7 @@ public void can_use_checkpoint_on_one_stream()
var checkPoint = 8L;//Zero based, ignore the first 9 events
Sum = 18;
//start at the checkpoint
Start(_stream1, checkPoint);
Start(_stream1, checkPoint, cancelWaitToken: TestContext.Current.CancellationToken);
//add the one recorded event
AssertEx.AtLeastModelVersion(this, 2, TimeSpan.FromMilliseconds(100), msg: $"Expected 2 got {Version}");
AssertEx.IsOrBecomesTrue(() => Sum == 20);
Expand All @@ -180,8 +180,8 @@ public void can_use_checkpoint_on_two_streams()
var checkPoint1 = 8L;//Zero based, ignore the first 9 events
var checkPoint2 = 5L;//Zero based, ignore the first 6 events
Sum = (9 * 2) + (6 * 3);
Start(_stream1, checkPoint1);
Start(_stream2, checkPoint2);
Start(_stream1, checkPoint1, cancelWaitToken: TestContext.Current.CancellationToken);
Start(_stream2, checkPoint2, cancelWaitToken: TestContext.Current.CancellationToken);
//add the recorded events 2 on stream 1 & 5 on stream 2
AssertEx.AtLeastModelVersion(this, 7, msg: $"Expected 7 got {Version}");
AssertEx.IsOrBecomesTrue(() => Sum == 50, msg: $"Expected 50 got {Sum}");
Expand All @@ -202,8 +202,8 @@ public void can_listen_to_the_same_stream_twice()
Assert.Equal(0, Version);
//weird but true
//n.b. Don't do this on purpose
Start(_stream1);
Start(_stream1);
Start(_stream1, cancelWaitToken: TestContext.Current.CancellationToken);
Start(_stream1, cancelWaitToken: TestContext.Current.CancellationToken);
//double events
AssertEx.AtLeastModelVersion(this, 22, msg: $"Expected 22 got {Version}");
AssertEx.IsOrBecomesTrue(() => Sum == 40);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void can_start_streams_by_aggregate()
var aggId = Guid.NewGuid();
var s1 = Namer.GenerateForAggregate(typeof(TestAggregate), aggId);
AppendEvents(1, _conn, s1, 7);
Start<TestAggregate>(aggId);
Start<TestAggregate>(aggId, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.IsOrBecomesTrue(() => Count == 1, 1000, msg: $"Expected 1 got {Count}");
AssertEx.IsOrBecomesTrue(() => Sum == 7);
}
Expand All @@ -72,15 +72,15 @@ public void can_start_streams_by_aggregate_category()
AppendEvents(1, _conn, s1, 7);
var s2 = Namer.GenerateForAggregate(typeof(ReadModelTestCategoryAggregate), Guid.NewGuid());
AppendEvents(1, _conn, s2, 5);
Start<ReadModelTestCategoryAggregate>(null, true);
Start<ReadModelTestCategoryAggregate>(null, true, cancelWaitToken: TestContext.Current.CancellationToken);

AssertEx.IsOrBecomesTrue(() => Count == 2, 1000, msg: $"Expected 2 got {Count}");
AssertEx.IsOrBecomesTrue(() => Sum == 12);
}
[Fact]
public void can_read_one_stream()
{
Start(_stream1);
Start(_stream1, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.IsOrBecomesTrue(() => Count == 10, 1000, msg: $"Expected 10 got {Count}");
AssertEx.IsOrBecomesTrue(() => Sum == 20);
//confirm checkpoints
Expand All @@ -90,8 +90,8 @@ public void can_read_one_stream()
[Fact]
public void can_read_two_streams()
{
Start(_stream1);
Start(_stream2);
Start(_stream1, cancelWaitToken: TestContext.Current.CancellationToken);
Start(_stream2, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.IsOrBecomesTrue(() => Count == 20, 1000, msg: $"Expected 20 got {Count}");
AssertEx.IsOrBecomesTrue(() => Sum == 50);
//confirm checkpoints
Expand All @@ -103,25 +103,25 @@ public void can_read_two_streams()
[Fact]
public void can_wait_for_one_stream_to_go_live()
{
Start(_stream1, null, true);
Start(_stream1, null, true, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.IsOrBecomesTrue(() => Count == 10, 100, msg: $"Expected 10 got {Count}");
AssertEx.IsOrBecomesTrue(() => Sum == 20, 100);
}
[Fact]
public void can_wait_for_two_streams_to_go_live()
{
Start(_stream1, null, true);
Start(_stream1, null, true, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.IsOrBecomesTrue(() => Count == 10, 100, msg: $"Expected 10 got {Count}");
AssertEx.IsOrBecomesTrue(() => Sum == 20, 100);

Start(_stream2, null, true);
Start(_stream2, null, true, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.IsOrBecomesTrue(() => Count == 20, 100, msg: $"Expected 20 got {Count}");
AssertEx.IsOrBecomesTrue(() => Sum == 50, 100);
}
[Fact]
public void can_listen_to_one_stream()
{
Start(_stream1);
Start(_stream1, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.IsOrBecomesTrue(() => Count == 10, 1000, msg: $"Expected 10 got {Count}");
AssertEx.IsOrBecomesTrue(() => Sum == 20);
//add more messages
Expand All @@ -136,8 +136,8 @@ public void can_listen_to_one_stream()
[Fact]
public void can_listen_to_two_streams()
{
Start(_stream1);
Start(_stream2);
Start(_stream1, cancelWaitToken: TestContext.Current.CancellationToken);
Start(_stream2, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.IsOrBecomesTrue(() => Count == 20, 1000, msg: $"Expected 20 got {Count}");
AssertEx.IsOrBecomesTrue(() => Sum == 50);
//add more messages
Expand All @@ -159,7 +159,7 @@ public void can_use_checkpoint_on_one_stream()
Count = 9;
Sum = 18;
//start at the checkpoint
Start(_stream1, checkPoint);
Start(_stream1, checkPoint, cancelWaitToken: TestContext.Current.CancellationToken);
//add the one recorded event
AssertEx.IsOrBecomesTrue(() => Count == 10, 100, msg: $"Expected 10 got {Count}");
AssertEx.IsOrBecomesTrue(() => Sum == 20);
Expand All @@ -179,8 +179,8 @@ public void can_use_checkpoint_on_two_streams()
var checkPoint2 = 5L;//Zero based, ignore the first 6 events
Count = (9) + (6);
Sum = (9 * 2) + (6 * 3);
Start(_stream1, checkPoint1);
Start(_stream2, checkPoint2);
Start(_stream1, checkPoint1, cancelWaitToken: TestContext.Current.CancellationToken);
Start(_stream2, checkPoint2, cancelWaitToken: TestContext.Current.CancellationToken);
//add the recorded events 2 on stream 1 & 5 on stream 2
AssertEx.IsOrBecomesTrue(() => Count == 20, 1000, msg: $"Expected 20 got {Count}");
AssertEx.IsOrBecomesTrue(() => Sum == 50, msg: $"Expected 50 got {Sum}");
Expand All @@ -201,8 +201,8 @@ public void can_listen_to_the_same_stream_twice()
Assert.Equal(0, Count);
//weird but true
//n.b. Don't do this on purpose
Start(_stream1);
Start(_stream1);
Start(_stream1, cancelWaitToken: TestContext.Current.CancellationToken);
Start(_stream1, cancelWaitToken: TestContext.Current.CancellationToken);
//double events
AssertEx.IsOrBecomesTrue(() => Count == 20, 1000, msg: $"Expected 20 got {Count}");
AssertEx.IsOrBecomesTrue(() => Sum == 40);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void can_restore_state_without_checkpoints() {
AssertEx.IsOrBecomesTrue(() => rm.Sum == 20);

//can manually start
rm.Start<SnapReadModelTestAggregate>(_aggId, 9, true);
rm.Start<SnapReadModelTestAggregate>(_aggId, 9, true, cancelWaitToken: TestContext.Current.CancellationToken);
AssertEx.IsOrBecomesTrue(() => rm.Count == 11, 1000);
AssertEx.IsOrBecomesTrue(() => rm.Sum == 25);
AppendEvents(1, _conn, _stream, 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit.runner.console" Version="2.9.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit.v3" Version="1.1.0" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/ReactiveDomain.Messaging.Tests/LaterServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void DelayPublishLoadTest() {
delay.Handle(new DelaySendEnvelope(timeSource, TimeSpan.FromMilliseconds(50), new TestMessage()));
}
timeSource.AdvanceTime(50);
cd.Wait(1000);
cd.Wait(1000, TestContext.Current.CancellationToken);
}
Assert.True(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - start <= 15000, $"elapsed {DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - start}");
}
Expand All @@ -135,7 +135,7 @@ public void DelayPublishLoadTestSystemTime() {
for (int i = 0; i < iterations; i++) {
delay.Handle(new DelaySendEnvelope(TimeSource.System, TimeSpan.FromMilliseconds(50), new TestMessage()));
}
cd.Wait(1000);
cd.Wait(1000, TestContext.Current.CancellationToken);
}
Assert.True(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - start <= 15000, $"elapsed {DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - start}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,8 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.3-beta1" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit.runner.console" Version="2.9.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="xunit.v3" Version="1.1.0" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public when_sending_commands_via_single_queued_dispatcher() {

[Fact]
public void send_cmd_msg_sequence_is_correct() {
var t1 = Task.Run(() => _dispatcher.Send(new TestCommands.Command1()));
var t1 = Task.Run(() => _dispatcher.Send(new TestCommands.Command1()), TestContext.Current.CancellationToken);
AssertEx.EnsureRunning(t1);
AssertEx.IsOrBecomesTrue(() => Interlocked.Read(ref _gotAck) == 1);
Assert.True(_commandHandleStarted == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public void can_cancel_commands_from_either_bus() {
{
var ts1 = new CancellationTokenSource();
CommandResponse response1 = null;
var t1 = Task.Run(()=> Assert.False(_fixture.LocalBus.TrySend(new TestCommands.RemoteCancel(ts1.Token), out response1)));
var t1 = Task.Run(()=> Assert.False(_fixture.LocalBus.TrySend(new TestCommands.RemoteCancel(ts1.Token), out response1)), TestContext.Current.CancellationToken);
ts1.Cancel();

var ts2 = new CancellationTokenSource();
CommandResponse response2 = null;
var t2 = Task.Run(() => Assert.False(_fixture.RemoteBus.TrySend(new TestCommands.RemoteCancel(ts2.Token), out response2)));
var t2 = Task.Run(() => Assert.False(_fixture.RemoteBus.TrySend(new TestCommands.RemoteCancel(ts2.Token), out response2)), TestContext.Current.CancellationToken);
ts2.Cancel();

AssertEx.EnsureComplete(t1, t2);
Expand Down
Loading