Skip to content

Commit a4fcf10

Browse files
authored
adjustments to run in .NET Framework, adding job to run tests for .NET Framework (#91)
1 parent d1299c2 commit a4fcf10

File tree

7 files changed

+33
-7
lines changed

7 files changed

+33
-7
lines changed

.github/workflows/integration.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ env:
1616

1717
jobs:
1818

19+
windows:
20+
name: windows
21+
runs-on: windows-latest
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: run redis-stack-server docker
25+
run: docker run -p 6379:6379 -d redis/redis-stack-server:edge
26+
- name: Restore dependencies
27+
run: dotnet restore
28+
- name: Build
29+
run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true
30+
- name: Test
31+
run: dotnet test --no-build --verbosity normal -f net481
1932
build_and_test:
2033
name: Build and test
2134
runs-on: ubuntu-latest
@@ -35,8 +48,10 @@ jobs:
3548
run: dotnet restore
3649
- name: Build
3750
run: dotnet build --no-restore /p:ContinuousIntegrationBuild=true
51+
- name: Test
52+
run: dotnet test -f net6.0 --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
3853
- name: Test
39-
run: dotnet test --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
54+
run: dotnet test -f net7.0 --no-build --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
4055
- name: Codecov
4156
uses: codecov/codecov-action@v3
4257
with:

src/NRedisStack/ResponseParser.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public static long ToLong(this RedisResult result)
4747

4848
public static double ToDouble(this RedisResult result)
4949
{
50+
if (result.ToString() == "nan")
51+
return double.NaN;
5052
if ((double?)result == null)
5153
throw new ArgumentNullException(nameof(result));
5254
return (double)result;

src/NRedisStack/Tdigest/TdigestCommands.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ public double Max(RedisKey key)
4444
/// <inheritdoc/>
4545
public double Min(RedisKey key)
4646
{
47-
return _db.Execute(TdigestCommandBuilder.Min(key)).ToDouble();
47+
var cmd = TdigestCommandBuilder.Min(key);
48+
var res =_db.Execute(cmd);
49+
return res.ToDouble();
4850
}
4951

5052
/// <inheritdoc/>

tests/NRedisStack.Tests/NRedisStack.Tests.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
4+
<TargetFrameworks>net6.0;net7.0;net462</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<LangVersion>latest</LangVersion>
78

89
<IsPackable>false</IsPackable>
910
</PropertyGroup>

tests/NRedisStack.Tests/Tdigest/TdigestTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ static Tuple<double, long> RandomValueWeight()
666666
{
667667
Random random = new Random();
668668

669-
return new Tuple<double, long>(random.NextDouble() * 10000, random.NextInt64() + 1);
669+
return new Tuple<double, long>(random.NextDouble() * 10000, random.Next() + 1);
670670
}
671671

672672
static Tuple<double, long>[] RandomValueWeightArray(int count)
@@ -687,7 +687,11 @@ static Tuple<double, long> DefinedValueWeight(double value, long weight)
687687
private static double[] WeightedValue(double value, int weight)
688688
{
689689
double[] values = new double[weight];
690-
Array.Fill(values, value);
690+
for (var i = 0; i < values.Length; i++)
691+
{
692+
values[i] = value;
693+
}
694+
691695
return values;
692696
}
693697
}

tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMADD.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using NRedisStack.DataTypes;
2+
using NRedisStack.Literals.Enums;
23
using NRedisStack.RedisStackCommands;
34
using StackExchange.Redis;
45
using Xunit;
@@ -88,7 +89,7 @@ public void TestOverrideMADD()
8889

8990
foreach (string key in keys)
9091
{
91-
ts.Create(key);
92+
ts.Create(key, duplicatePolicy: TsDuplicatePolicy.MAX);
9293
}
9394

9495
List<DateTime> oldTimeStamps = new List<DateTime>();

tests/NRedisStack.Tests/TimeSeries/TestAPI/TestMAddAsync.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using NRedisStack.DataTypes;
2+
using NRedisStack.Literals.Enums;
23
using NRedisStack.RedisStackCommands;
34
using StackExchange.Redis;
45
using Xunit;
@@ -82,7 +83,7 @@ public async Task TestOverrideMAdd()
8283

8384
foreach (var key in keys)
8485
{
85-
await ts.CreateAsync(key);
86+
await ts.CreateAsync(key, duplicatePolicy: TsDuplicatePolicy.MAX);
8687
}
8788

8889
var oldTimeStamps = new List<DateTime>();

0 commit comments

Comments
 (0)