|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Diagnostics; |
| 4 | +using System.Linq; |
| 5 | +using System.Reflection; |
| 6 | +using System.Text; |
| 7 | +using System.Threading; |
| 8 | +using System.Threading.Tasks; |
| 9 | +using RabbitMQ.Stream.Client; |
| 10 | +using Xunit; |
| 11 | +using Xunit.Abstractions; |
| 12 | +using Xunit.Sdk; |
| 13 | + |
| 14 | +namespace Tests |
| 15 | +{ |
| 16 | + |
| 17 | + |
| 18 | + [Collection("Sequential")] |
| 19 | + public class StreamSpecTests |
| 20 | + { |
| 21 | + private readonly ITestOutputHelper testOutputHelper; |
| 22 | + |
| 23 | + public StreamSpecTests(ITestOutputHelper testOutputHelper) |
| 24 | + { |
| 25 | + this.testOutputHelper = testOutputHelper; |
| 26 | + } |
| 27 | + |
| 28 | + |
| 29 | + [Fact] |
| 30 | + [WaitTestBeforeAfter] |
| 31 | + public void DefaultStreamSpecMustHaveAtLeastQueueLeaderLocator() |
| 32 | + { |
| 33 | + StreamSpec actualSpec = new StreamSpec("theStreamName"); |
| 34 | + StreamSpec expectedSpec = new StreamSpec("theStreamName") { |
| 35 | + LeaderLocator = LeaderLocator.LeastLeaders |
| 36 | + }; |
| 37 | + Assert.Equal(expectedSpec.Args, actualSpec.Args); |
| 38 | + |
| 39 | + } |
| 40 | + |
| 41 | + |
| 42 | + [Fact] |
| 43 | + [WaitTestBeforeAfter] |
| 44 | + public void CanOverrideAnyStreamSpecAttributes() |
| 45 | + { |
| 46 | + StreamSpec spec = new StreamSpec("theStreamName"); |
| 47 | + spec.MaxAge = TimeSpan.FromHours(3); |
| 48 | + spec.MaxLengthBytes = 10000; |
| 49 | + spec.LeaderLocator = LeaderLocator.Random; // this is an override because the spec has already a default value |
| 50 | + |
| 51 | + // can override any settings being set |
| 52 | + spec.MaxAge = TimeSpan.FromHours(5); |
| 53 | + spec.MaxLengthBytes = 20000; |
| 54 | + |
| 55 | + |
| 56 | + StreamSpec expectedSpec = new StreamSpec("theStreamName") { |
| 57 | + LeaderLocator = LeaderLocator.Random, |
| 58 | + MaxLengthBytes = 20000, |
| 59 | + MaxAge = TimeSpan.FromHours(5) |
| 60 | + }; |
| 61 | + Assert.Equal(expectedSpec.Args, spec.Args); |
| 62 | + } |
| 63 | + |
| 64 | + } |
| 65 | +} |
0 commit comments