Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ jobs:
- name: Build
run: dotnet build --no-restore --configuration Release -p:Version=${{ steps.gitversion.outputs.semVer }} -p:ContinuousIntegrationBuild=true -p:Deterministic=true
- name: Test
run: dotnet test --no-build --configuration Release --verbosity normal --filter Category!=Explicit
# xUnit v3 runs on Microsoft.Testing.Platform (global.json). Exit code 8 means a project ran no tests,
# as the transport test projects only contain Explicit tests.
run: dotnet test --solution Obvs.sln --no-build --configuration Release -- --filter-not-trait "Category=Explicit" --ignore-exit-code 8
- name: Pack
if: github.event_name == 'push'
run: |
Expand Down
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.11.0"/>
<!-- Keep in step with System.Reactive -->
<PackageVersion Include="Microsoft.Reactive.Testing" Version="7.0.0"/>
<PackageVersion Include="xunit" Version="2.9.3"/>
<PackageVersion Include="xunit.v3" Version="4.0.2"/>
<PackageVersion Include="xunit.runner.visualstudio" Version="4.0.1"/>
</ItemGroup>
</Project>
3 changes: 2 additions & 1 deletion Obvs.ActiveMQ.Tests/Obvs.ActiveMQ.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Company>Christopher Read</Company>
<Copyright>Copyright © Christopher Read 2014</Copyright>
Expand All @@ -10,7 +11,7 @@
<PackageReference Include="FakeItEasy" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Reactive.Testing" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
3 changes: 2 additions & 1 deletion Obvs.Kafka.Tests/Obvs.Kafka.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FakeItEasy" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Reactive.Testing" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions Obvs.Kafka.Tests/TestMessageSendAndReceive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ public async Task TestSendAndReceiveMessage()

var delay1 = TimeSpan.FromSeconds(2);
Console.WriteLine($"Waiting {delay1}...");
await Task.Delay(delay1);
await Task.Delay(delay1, TestContext.Current.CancellationToken);

await _publisher.PublishAsync(new TestMessage($"hello world {DateTime.Now}"));
await _publisher.PublishAsync(new TestMessage($"hello world {DateTime.Now}"));
await _publisher.PublishAsync(new TestMessage($"hello world {DateTime.Now}"));

var delay2 = TimeSpan.FromSeconds(2);
Console.WriteLine($"Waiting {delay2}...");
await Task.Delay(delay2);
await Task.Delay(delay2, TestContext.Current.CancellationToken);

Assert.NotEmpty(messages);
Assert.Equal(3, messages.Count);
Expand Down
3 changes: 2 additions & 1 deletion Obvs.Logging.Tests/Obvs.Logging.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FakeItEasy" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
3 changes: 2 additions & 1 deletion Obvs.Monitoring.Tests/Obvs.Monitoring.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Company>Christopher Read</Company>
<Copyright>Copyright © Christopher Read 2014</Copyright>
Expand All @@ -10,7 +11,7 @@
<PackageReference Include="FakeItEasy" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Reactive.Testing" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
3 changes: 2 additions & 1 deletion Obvs.NATS.Tests/Obvs.NATS.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FakeItEasy" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Reactive.Testing" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
2 changes: 1 addition & 1 deletion Obvs.NATS.Tests/TestServiceBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public async Task TestBasicSendReceiveOfAllMessageTypes()
var response = await bus.GetResponse<TestResponse>(new TestRequest());
Console.WriteLine(response);

await Task.Delay(TimeSpan.FromSeconds(1));
await Task.Delay(TimeSpan.FromSeconds(1), TestContext.Current.CancellationToken);

((IDisposable)bus).Dispose();
}
Expand Down
2 changes: 1 addition & 1 deletion Obvs.NATS.Tests/TestSourceAndPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task TestSendAndReceiveMessage()
await publisher.PublishAsync(new TestMessage {Id = i});
}

await Task.Delay(TimeSpan.FromSeconds(1));
await Task.Delay(TimeSpan.FromSeconds(1), TestContext.Current.CancellationToken);
subscription.Dispose();
}
}
Expand Down
3 changes: 2 additions & 1 deletion Obvs.NetMQ.Tests/Obvs.NetMQ.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FakeItEasy" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Reactive.Testing" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
38 changes: 23 additions & 15 deletions Obvs.NetMQ.Tests/TestPublishSubscribe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace Obvs.NetMQ.Tests
{
// Each test uses its own port, clear of the ranges TestServiceBusWithNetMq binds,
// because xUnit runs test classes in parallel
public class TestPublishSubscribe
{
[Fact, Trait("Category", "Explicit")]
Expand All @@ -29,7 +31,7 @@ public async Task TestSendingAndReceivingStringsOverLocalHost()

}, err => Console.WriteLine("Error: " + err));

IMessageSource<IMessage> source = new MessageSource<IMessage>("tcp://localhost:5556",
IMessageSource<IMessage> source = new MessageSource<IMessage>("tcp://localhost:5560",
new IMessageDeserializer<IMessage>[]
{
new JsonMessageDeserializer<TestMessage1>(),
Expand All @@ -39,7 +41,7 @@ public async Task TestSendingAndReceivingStringsOverLocalHost()

var sub = source.Messages.Subscribe(observer);

IMessagePublisher<IMessage> publisher = new MessagePublisher<IMessage>("tcp://localhost:5556",
IMessagePublisher<IMessage> publisher = new MessagePublisher<IMessage>("tcp://localhost:5560",
new JsonMessageSerializer(), topic);

await publisher.PublishAsync(new TestMessage1 { Id = 1 });
Expand All @@ -48,7 +50,11 @@ public async Task TestSendingAndReceivingStringsOverLocalHost()
await publisher.PublishAsync(new TestMessage2 { Id = 2 });
await publisher.PublishAsync(new TestMessage1 { Id = 3 });
await publisher.PublishAsync(new TestMessage2 { Id = 3 });
await Task.Delay(TimeSpan.FromSeconds(2));
await Task.Delay(TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken);

sub.Dispose();
source.Dispose();
publisher.Dispose();

Assert.True(messages.OfType<TestMessage1>().Any(msg => msg.Id == 1), "TestMessage1 1 not received");
Assert.True(messages.OfType<TestMessage1>().Any(msg => msg.Id == 2), "TestMessage1 2 not received");
Expand All @@ -57,9 +63,6 @@ public async Task TestSendingAndReceivingStringsOverLocalHost()
Assert.True(messages.OfType<TestMessage2>().Any(msg => msg.Id == 1), "TestMessage2 1 not received");
Assert.True(messages.OfType<TestMessage2>().Any(msg => msg.Id == 2), "TestMessage2 2 not received");
Assert.True(messages.OfType<TestMessage2>().Any(msg => msg.Id == 3), "TestMessage2 3 not received");

sub.Dispose();
source.Dispose();
}

[Fact, Trait("Category", "Explicit")]
Expand All @@ -76,7 +79,7 @@ public async Task TestSendingAndReceivingBytesOverLocalHost()

}, err => Console.WriteLine("Error: " + err));

IMessageSource<IMessage> source = new MessageSource<IMessage>("tcp://localhost:5556",
IMessageSource<IMessage> source = new MessageSource<IMessage>("tcp://localhost:5561",
new IMessageDeserializer<IMessage>[]
{
new ProtoBufMessageDeserializer<TestMessage1>(),
Expand All @@ -86,7 +89,7 @@ public async Task TestSendingAndReceivingBytesOverLocalHost()

var sub = source.Messages.Subscribe(observer);

IMessagePublisher<IMessage> publisher = new MessagePublisher<IMessage>("tcp://localhost:5556",
IMessagePublisher<IMessage> publisher = new MessagePublisher<IMessage>("tcp://localhost:5561",
new ProtoBufMessageSerializer(), topic);

await publisher.PublishAsync(new TestMessage1 { Id = 1 });
Expand All @@ -95,7 +98,11 @@ public async Task TestSendingAndReceivingBytesOverLocalHost()
await publisher.PublishAsync(new TestMessage2 { Id = 2 });
await publisher.PublishAsync(new TestMessage1 { Id = 3 });
await publisher.PublishAsync(new TestMessage2 { Id = 3 });
await Task.Delay(TimeSpan.FromSeconds(2));
await Task.Delay(TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken);

sub.Dispose();
source.Dispose();
publisher.Dispose();

Assert.True(messages.OfType<TestMessage1>().Any(msg => msg.Id == 1), "TestMessage1 1 not received");
Assert.True(messages.OfType<TestMessage1>().Any(msg => msg.Id == 2), "TestMessage1 2 not received");
Expand All @@ -104,9 +111,6 @@ public async Task TestSendingAndReceivingBytesOverLocalHost()
Assert.True(messages.OfType<TestMessage2>().Any(msg => msg.Id == 1), "TestMessage2 1 not received");
Assert.True(messages.OfType<TestMessage2>().Any(msg => msg.Id == 2), "TestMessage2 2 not received");
Assert.True(messages.OfType<TestMessage2>().Any(msg => msg.Id == 3), "TestMessage2 3 not received");

sub.Dispose();
source.Dispose();
}

[Fact, Trait("Category", "Explicit")]
Expand All @@ -117,8 +121,10 @@ public async Task TestMessagesLongerThan32Characters()

const string topic = "TestTopicxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
IDisposable sub;
MessageSource<IMessage> source;
MessagePublisher<IMessage> publisher;
{
var source = new MessageSource<IMessage>("tcp://localhost:5557",
source = new MessageSource<IMessage>("tcp://localhost:5562",
new IMessageDeserializer<IMessage>[]
{
new ProtoBufMessageDeserializer<TestMessageWhereTypeIsVeryMuchDefinitionLongerThen32Characters>(),
Expand All @@ -134,7 +140,7 @@ public async Task TestMessagesLongerThan32Characters()
}

{
var publisher = new MessagePublisher<IMessage>("tcp://localhost:5557",
publisher = new MessagePublisher<IMessage>("tcp://localhost:5562",
new ProtoBufMessageSerializer(),
topic);

Expand All @@ -147,9 +153,11 @@ await publisher.PublishAsync(new TestMessageWhereTypeIsVeryMuchDefinitionLongerT
}
}

await Task.Delay(TimeSpan.FromSeconds(2));
await Task.Delay(TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken);

sub.Dispose();
source.Dispose();
publisher.Dispose();
}

[ProtoContract]
Expand Down
7 changes: 6 additions & 1 deletion Obvs.NetMQ.Tests/TestServiceBusWithNetMq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ public async Task TestServiceEndpointsOverLocalHostSockets()
serviceBusClient2.GetResponses(new TestRequest1 { Id = 6 }).Subscribe(fakeClient1);

// wait some time until we think all messages have been sent and received
await Task.Delay(TimeSpan.FromSeconds(3));
await Task.Delay(TimeSpan.FromSeconds(3), TestContext.Current.CancellationToken);

// dispose before asserting, so a failed assertion doesn't leave sockets bound for other tests
((IDisposable)serviceBus).Dispose();
((IDisposable)serviceBusClient1).Dispose();
((IDisposable)serviceBusClient2).Dispose();

// test we got everything we expected
Assert.True(messages.OfType<TestCommand1>().Count() == 2, "TestCommand1");
Expand Down
3 changes: 2 additions & 1 deletion Obvs.RabbitMQ.Tests/Obvs.RabbitMQ.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
Expand All @@ -11,7 +12,7 @@
<PackageReference Include="FakeItEasy" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Reactive.Testing" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
4 changes: 2 additions & 2 deletions Obvs.RabbitMQ.Tests/TestSendingAndReceiving.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task TestSendReceiveAs(string format)
await messagePublisher.PublishAsync(message);
}

await Task.Delay(TimeSpan.FromSeconds(2));
await Task.Delay(TimeSpan.FromSeconds(2), TestContext.Current.CancellationToken);

Assert.True(receivedMessages1.Count == 7, "Incorrect number of messages received for first subscription");
Assert.True(receivedMessages2.Count == 7, "Incorrect number of messages received for second subscription");
Expand All @@ -80,7 +80,7 @@ public async Task TestSendReceiveAs(string format)
sub2.Dispose();
messagePublisher.Dispose();
messageSource.Dispose();
await connection.Value.CloseAsync();
await connection.Value.CloseAsync(cancellationToken: TestContext.Current.CancellationToken);
}

private static IMessagePublisher<IMessage> CreateMessagePublisher(string format, Lazy<IConnection> connection,
Expand Down
2 changes: 1 addition & 1 deletion Obvs.RabbitMQ.Tests/TestServiceBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task ShouldSendAndReceiveMessagesOverServiceBus()
var sub6 = serviceBus.GetResponses(new TestRequest { Id = 456 }).Subscribe(observer);

// wait some time until we think all messages have been sent and received from RabbitMQ
await Task.Delay(TimeSpan.FromSeconds(1));
await Task.Delay(TimeSpan.FromSeconds(1), TestContext.Current.CancellationToken);

// test we got everything we expected
Assert.True(messages.OfType<TestCommand>().Count() == 1, "TestCommand not received");
Expand Down
3 changes: 2 additions & 1 deletion Obvs.Serialization.Tests/Obvs.Serialization.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Company>Christopher Read</Company>
<Copyright>Copyright © Christopher Read 2014</Copyright>
Expand All @@ -10,7 +11,7 @@
<PackageReference Include="FakeItEasy" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Reactive.Testing" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
3 changes: 2 additions & 1 deletion Obvs.Tests/Obvs.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<Company>Christopher Read</Company>
<Copyright>Copyright © Christopher Read 2014</Copyright>
Expand All @@ -10,7 +11,7 @@
<PackageReference Include="FakeItEasy" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.Reactive.Testing" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.v3" />
<PackageReference Include="xunit.runner.visualstudio">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
1 change: 0 additions & 1 deletion Obvs.Tests/TestServiceBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
using Obvs.Monitoring;
using Obvs.Types;
using Xunit;
using Xunit.Abstractions;

namespace Obvs.Tests
{
Expand Down
Loading
Loading