Skip to content

Commit 0fd5f71

Browse files
committed
fix the problem
1 parent b164116 commit 0fd5f71

File tree

12 files changed

+45
-29
lines changed

12 files changed

+45
-29
lines changed

BeetleX.Redis.XUnitTest/BeetleX.Redis.XUnitTest.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

9+
<ItemGroup>
10+
<Compile Remove="DBTester_BACKUP_37104.cs" />
11+
<Compile Remove="DBTester_BASE_37104.cs" />
12+
<Compile Remove="DBTester_LOCAL_37104.cs" />
13+
<Compile Remove="DBTester_REMOTE_37104.cs" />
14+
</ItemGroup>
15+
916
<ItemGroup>
1017
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
1118
<PackageReference Include="Northwind.Data" Version="1.2.3" />

BeetleX.Redis.XUnitTest/DBTester.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,9 @@ public class DBTester
1616
public DBTester(ITestOutputHelper output)
1717
{
1818
this.Console = output;
19-
//DB.Host.AddWriteHost("192.168.2.19", 6378, true);
20-
<<<<<<< HEAD
21-
DB.Host.AddWriteHost("192.168.2.19", 6379);
22-
=======
2319
DB.Host.AddWriteHost("127.0.0.1");
24-
DB.KeyPrefix = "bbq";
25-
>>>>>>> KeyPrefix
26-
20+
DB.KeyPrefix = "BeetleX";
21+
DB.AutoPing = false;
2722
}
2823

2924
private RedisDB DB = new RedisDB(0);
@@ -100,15 +95,15 @@ public async void Set()
10095

10196
var emptyValue = await DB.Get<string>("test");
10297
Write(emptyValue);
103-
Assert.Equal<string>(emptyValue, "");
98+
Assert.Equal<string>(emptyValue, null);
10499

105100

106101
var nullResult = await DB.Set("test", null);
107102
Write(nullResult);
108103

109104
var nullValue = await DB.Get<string>("test");
110105
Write(nullValue);
111-
Assert.Equal<string>(nullValue, "");
106+
Assert.Equal<string>(nullValue, null);
112107

113108
}
114109

BeetleX.Redis.XUnitTest/HashTableTester.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public HashTableTester(ITestOutputHelper output)
1212
{
1313
this.Console = output;
1414
DB.Host.AddWriteHost("localhost");
15-
DB.KeyPrefix = "KV";
15+
DB.KeyPrefix = "BeetleX";
1616
}
1717

1818
private RedisDB DB = new RedisDB(0);
@@ -73,15 +73,15 @@ public async void HGet()
7373

7474
var emptyValue = await table.Get<string>("fieldEmpty");
7575
Write(emptyValue);
76-
Assert.Equal<string>(emptyValue, "");
76+
Assert.Equal<string>(emptyValue, null);
7777

7878

7979
var nullResult = await table.Set("fieldNull", null);
8080
Write(nullResult);
8181

8282
var nullValue = await table.Get<string>("fieldNull");
8383
Write(nullValue);
84-
Assert.Equal<string>(nullValue, "");
84+
Assert.Equal<string>(nullValue, null);
8585

8686

8787
}
@@ -134,9 +134,9 @@ public async void HLen()
134134
public async void HMGet()
135135
{
136136
await DB.Flushall();
137-
var table = DB.CreateHashTable("myhash");
138-
Write(await table.MSet(("field1", "hello"), ("field2", "world")));
139-
var values = await table.Get<string, string, string>("field1", "field2", "nofield");
137+
var table = DB.CreateHashTable("myhash");
138+
Write(await table.MSet(("field1", "hello"), ("field2", "world")));
139+
var values = await table.Get<string, string, string>("field1", "field2", "nofield");
140140
Write(values.Item1);
141141
Write(values.Item2);
142142
Write(values.Item3);

BeetleX.Redis.XUnitTest/SequenceTest.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public SequenceTest(ITestOutputHelper output)
1414
{
1515
this.Console = output;
1616
DB.Host.AddWriteHost("localhost");
17+
DB.KeyPrefix = "BeetleX";
1718
}
1819

1920
private RedisDB DB = new RedisDB(0);
@@ -50,7 +51,7 @@ public async void ZSCORE()
5051
var sequeue = DB.CreateSequence("seq2");
5152
var count = await sequeue.ZAdd((4.14, "bca"));
5253
var value = await sequeue.ZScore("bca");
53-
Assert.Equal<double>(value, 4.14);
54+
Assert.Equal<double>(value.Value, 4.14);
5455

5556
var unknownMemberValue = await sequeue.ZScore("unknownseq");
5657
Assert.Equal<double?>(unknownMemberValue, null);
@@ -64,10 +65,10 @@ public async void ZINCRBY()
6465
var sequeue = DB.CreateSequence("seq2");
6566
var count = await sequeue.ZAdd((4.14, member));
6667
var value = await sequeue.ZScore(member);
67-
Assert.Equal<double>(value, 4.14);
68+
Assert.Equal<double>(value.Value, 4.14);
6869
await sequeue.ZIncrby(5, member);
6970
value = await sequeue.ZScore(member);
70-
Assert.Equal<double>(value, 9.14);
71+
Assert.Equal<double>(value.Value, 9.14);
7172
}
7273
[Fact]
7374
public async void ZCARD()
@@ -161,7 +162,7 @@ public async void ZRANK()
161162
var sequeue = DB.CreateSequence("seq2");
162163
await sequeue.ZAdd((100, "A1"), (200, "A2"), (300, "A3"), (400, "A4"));
163164
var value = await sequeue.ZRank("A4");
164-
Assert.Equal<long>(value, 3);
165+
Assert.Equal<long>(value.Value, 3);
165166

166167

167168
var unknownMemberValue = await sequeue.ZRank("unknownseq");

BeetleX.Redis.XUnitTest/SetsTester.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public SetsTester(ITestOutputHelper output)
1717
DefaultRedis.Instance.Host.AddWriteHost("localhost");
1818
DefaultRedis.Instance.DataFormater = new JsonFormater();
1919
DB = DefaultRedis.Instance.Cloneable();
20-
DB.KeyPrefix = "HENRY";
20+
DB.KeyPrefix = "BeetleX";
2121
}
2222

2323
private RedisDB DB;

src/BeetleX.Redis.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
5-
<Version>1.2.4</Version>
5+
<Version>1.3.1</Version>
66
<Company>beetlex.io</Company>
77
<Authors>henryfan</Authors>
88
<Copyright>Copyright © beetlex.io 2019-2021</Copyright>
@@ -17,11 +17,11 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="BeetleX" Version="1.6.5.41" />
20+
<PackageReference Include="BeetleX" Version="1.6.5.62" />
2121
<PackageReference Include="BeetleX.Tracks" Version="0.7.5" />
2222
<PackageReference Include="MessagePack" Version="2.1.115" />
2323
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
24-
<PackageReference Include="protobuf-net" Version="2.4.6" />
24+
<PackageReference Include="protobuf-net" Version="3.0.101" />
2525
<PackageReference Include="System.Text.Json" Version="5.0.2" />
2626
</ItemGroup>
2727

src/Command.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ static Command()
2929

3030
public static byte[] GetMsgHeaderLengthData(int length)
3131
{
32+
if (length <= 0)
33+
return null;
3234
if (length > MAX_LENGTH_TABLE)
3335
return null;
3436
return mMsgHeaderLenData[length - 1];
@@ -38,6 +40,8 @@ public static byte[] GetMsgHeaderLengthData(int length)
3840

3941
public static byte[] GetBodyHeaderLenData(int length)
4042
{
43+
if (length <= 0)
44+
return null;
4145
if (length > MAX_LENGTH_TABLE)
4246
return null;
4347
return mBodyHeaderLenData[length - 1];

src/Commands/HSET.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ public override void OnExecute()
2929
base.OnExecute();
3030
OnWriteKey(Key);
3131
AddText(Field);
32+
if (Value == null)
33+
Value = string.Empty;
3234
AddData(Value);
3335
}
3436

src/Commands/SET.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public override void OnExecute()
3131
{
3232
base.OnExecute();
3333
OnWriteKey(Key);
34+
if (Data == null)
35+
Data = string.Empty;
3436
AddData(Data);
3537
if (TimeOut > 0)
3638
{

src/Commands/ZUNIONSTORE.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public override void OnExecute()
3737
AddText(Items.Length);
3838
foreach (var item in Items)
3939
{
40-
AddText(item.key);
40+
OnWriteKey(item.key);
4141
}
4242
AddText("WEIGHTS");
4343
foreach (var item in Items)

0 commit comments

Comments
 (0)