|
3 | 3 | using NRedisStack.RedisStackCommands; |
4 | 4 | using NRedisStack.Literals.Enums; |
5 | 5 | using Xunit; |
6 | | -using System.Runtime.CompilerServices; |
7 | 6 |
|
8 | 7 | namespace NRedisStack.Tests.TimeSeries.TestAPI |
9 | 8 | { |
@@ -136,5 +135,33 @@ public void TestCreateAndIgnoreValues() |
136 | 135 | Assert.Equal(11, (long)info[j + 1]); |
137 | 136 | Assert.Equal(12, (long)info[k + 1]); |
138 | 137 | } |
| 138 | + |
| 139 | + [Fact] |
| 140 | + public void TestParamsBuilder() |
| 141 | + { |
| 142 | + TsCreateParams parameters = new TsCreateParamsBuilder() |
| 143 | + .AddChunkSizeBytes(1000) |
| 144 | + .AddDuplicatePolicy(TsDuplicatePolicy.FIRST) |
| 145 | + .AddIgnoreValues(11, 12) |
| 146 | + .AddLabels(new List<TimeSeriesLabel>() { new TimeSeriesLabel("key", "value") }) |
| 147 | + .AddRetentionTime(5000) |
| 148 | + .AddUncompressed(true).build(); |
| 149 | + |
| 150 | + var command = TimeSeriesCommandsBuilder.Create(key, parameters); |
| 151 | + var expectedArgs = new object[] { key, "RETENTION", 5000L, "CHUNK_SIZE", 1000L, "LABELS", "key", "value", "UNCOMPRESSED", "DUPLICATE_POLICY", "FIRST", "IGNORE", 11L, 12L }; |
| 152 | + Assert.Equal(expectedArgs, command.Args); |
| 153 | + |
| 154 | + parameters = new TsCreateParamsBuilder() |
| 155 | + .AddChunkSizeBytes(1000) |
| 156 | + .AddDuplicatePolicy(TsDuplicatePolicy.FIRST) |
| 157 | + .AddIgnoreValues(11, 12) |
| 158 | + .AddLabels(new List<TimeSeriesLabel>() { new TimeSeriesLabel("key", "value") }) |
| 159 | + .AddRetentionTime(5000) |
| 160 | + .AddUncompressed(false).build(); |
| 161 | + |
| 162 | + command = TimeSeriesCommandsBuilder.Create(key, parameters); |
| 163 | + expectedArgs = new object[] { key, "RETENTION", 5000L, "CHUNK_SIZE", 1000L, "LABELS", "key", "value", "COMPRESSED", "DUPLICATE_POLICY", "FIRST", "IGNORE", 11L, 12L }; |
| 164 | + Assert.Equal(expectedArgs, command.Args); |
| 165 | + } |
139 | 166 | } |
140 | 167 | } |
0 commit comments