Skip to content

Commit

Permalink
Add wilcard tests
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasfp committed Feb 7, 2024
1 parent 49203e6 commit ff39161
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 2 additions & 0 deletions tests/NATS.Client.JetStream.Tests/ConsumerConsumeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class ConsumerConsumeTest
[Theory]
[InlineData("Invalid.DotName")]
[InlineData("Invalid SpaceName")]
[InlineData("Invalid*StarName")]
[InlineData("Invalid>WildcardName")]
[InlineData(null)]
public async Task Consumer_stream_invalid_name_test(string? streamName)
{
Expand Down
10 changes: 2 additions & 8 deletions tests/NATS.Client.JetStream.Tests/JetStreamTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,11 @@ public class JetStreamTest

public JetStreamTest(ITestOutputHelper output) => _output = output;

[Fact]
public void Invalid_stream_validation_test()
{
Assert.Throws<ArgumentNullException>(() => NatsJSContext.ThrowIfInvalidStreamName(null!));
Assert.Throws<ArgumentException>(() => NatsJSContext.ThrowIfInvalidStreamName("Invalid.DotName"));
Assert.Throws<ArgumentException>(() => NatsJSContext.ThrowIfInvalidStreamName("Invalid SpaceName"));
}

[Theory]
[InlineData("Invalid.DotName")]
[InlineData("Invalid SpaceName")]
[InlineData("Invalid*StarName")]
[InlineData("Invalid>WildcardName")]
[InlineData(null)]
public async Task Stream_invalid_name_test(string? streamName)
{
Expand Down
10 changes: 10 additions & 0 deletions tests/NATS.Client.JetStream.Tests/NatsJSContextTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,14 @@ public void InterfaceShouldHaveSamePublicPropertiesEventsAndMethodAsClass()
interfaceMethods.Select(m => m.Name).Should().Contain(name);
}
}

[Fact]
public void Invalid_stream_validation_test()
{
Assert.Throws<ArgumentNullException>(() => NatsJSContext.ThrowIfInvalidStreamName(null!));
Assert.Throws<ArgumentException>(() => NatsJSContext.ThrowIfInvalidStreamName("Invalid.DotName"));
Assert.Throws<ArgumentException>(() => NatsJSContext.ThrowIfInvalidStreamName("Invalid SpaceName"));
Assert.Throws<ArgumentException>(() => NatsJSContext.ThrowIfInvalidStreamName("Invalid*StarName"));
Assert.Throws<ArgumentException>(() => NatsJSContext.ThrowIfInvalidStreamName("Invalid>WildcardName"));
}
}

0 comments on commit ff39161

Please sign in to comment.