Skip to content

Commit 6db8893

Browse files
Federico ColomboFederico Colombo
authored andcommitted
fix pack.cmd and unit tests, increasing timeout for tests
1 parent 5c82211 commit 6db8893

File tree

6 files changed

+39
-35
lines changed

6 files changed

+39
-35
lines changed

src/pack.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ del "CachingFramework.Redis.MsgPack\bin\release\*.nupkg"
33
del "CachingFramework.Redis.MemoryPack\bin\release\*.nupkg"
44
del "CachingFramework.Redis.NewtonsoftJson\bin\release\*.nupkg"
55

6-
dotnet build -c Release
6+
dotnet build ..\CachingFramework.slnx -c Release
77

88
dotnet pack "CachingFramework.Redis/" -c Release
99
dotnet pack "CachingFramework.Redis.MsgPack/" -c Release

test/CachingFramework.Redis.UnitTest/Common.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static DateTime ServerNow
5151
}
5252

5353
public static int[] VersionInfo { get; set; }
54-
public static string Config = "localhost:6379, allowAdmin=true";
54+
public static string Config = "localhost:6379, allowAdmin=true, connectTimeout=10000, syncTimeout=30000, asyncTimeout=30000";
5555

5656
static Common()
5757
{

test/CachingFramework.Redis.UnitTest/UnitTestGeo.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static void ClassInitialize()
2323
_coordLondon = new GeoCoordinate(51.5073509, -0.1277583);
2424
}
2525

26-
[Test, TestCaseSource(typeof(Common), "All")]
26+
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
2727
public void UT_Geo_GeoAdd(RedisContext context)
2828
{
2929
var key = $"UT_Geo_GeoAdd-{Common.GetUId()}";
@@ -37,7 +37,7 @@ public void UT_Geo_GeoAdd(RedisContext context)
3737
Assert.AreEqual(_coordZapopan.Longitude, coord.Longitude, 0.00001);
3838
}
3939

40-
[Test, TestCaseSource(typeof(Common), "All")]
40+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
4141
public void UT_Geo_GeoPos(RedisContext context)
4242
{
4343
var key = $"UT_Geo_GeoPos-{Common.GetUId()}";
@@ -57,7 +57,7 @@ public void UT_Geo_GeoPos(RedisContext context)
5757
Assert.AreEqual(0, coordGetZero.Longitude, 0.00001);
5858
}
5959

60-
[Test, TestCaseSource(typeof(Common), "All")]
60+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
6161
public void UT_Geo_GeoPosMultiple(RedisContext context)
6262
{
6363
var key = $"UT_Geo_GeoPosMultiple-{Common.GetUId()}";
@@ -77,7 +77,7 @@ public void UT_Geo_GeoPosMultiple(RedisContext context)
7777
Assert.AreEqual(null, coords[1]);
7878
}
7979

80-
[Test, TestCaseSource(typeof(Common), "All")]
80+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
8181
public void UT_Geo_GeoDistance(RedisContext context)
8282
{
8383
var key = $"UT_Geo_GeoDistance-{Common.GetUId()}";
@@ -97,7 +97,7 @@ public void UT_Geo_GeoDistance(RedisContext context)
9797
}
9898

9999
#if (NET462)
100-
[Test, TestCaseSource(typeof(Common), "All")]
100+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
101101
public void UT_Geo_GeoDistanceDirect(RedisContext context)
102102
{
103103
var key = $"UT_Geo_GeoDistanceDirect-{Common.GetUId()}";
@@ -112,7 +112,7 @@ public void UT_Geo_GeoDistanceDirect(RedisContext context)
112112
Assert.AreEqual(385, km, 15);
113113
}
114114
#endif
115-
[Test, TestCaseSource(typeof(Common), "All")]
115+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
116116
public void UT_Geo_GeoHash(RedisContext context)
117117
{
118118
var key = $"UT_Geo_GeoHash-{Common.GetUId()}";

test/CachingFramework.Redis.UnitTest/UnitTestPubSub.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace CachingFramework.Redis.UnitTest
1111
[TestFixture]
1212
public class UnitTestPubSub
1313
{
14-
[Test, TestCaseSource(typeof(Common), "All")]
14+
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1515
public void UT_PubSub_SingleSubscribe(RedisContext context)
1616
{
1717
var ch = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -29,13 +29,13 @@ public void UT_PubSub_SingleSubscribe(RedisContext context)
2929
{
3030
context.PubSub.Publish(ch, t);
3131
}
32-
Thread.Sleep(500);
32+
Thread.Sleep(2000);
3333
Assert.AreEqual(users.Count, usersList.Count);
3434
Assert.IsTrue(users.All(u => usersList.Any(ul => ul.Id == u.Id)));
3535
context.PubSub.Unsubscribe(ch);
3636
}
3737

38-
[Test, TestCaseSource(typeof(Common), "All")]
38+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
3939
public void UT_PubSub_SingleUnsubscribe(RedisContext context)
4040
{
4141
var ch = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -55,7 +55,7 @@ public void UT_PubSub_SingleUnsubscribe(RedisContext context)
5555
}
5656

5757
#if (NET462)
58-
[Test, TestCaseSource(typeof(Common), "Bin")]
58+
[Test, TestCaseSource(typeof(Common), nameof(Common.Bin))]
5959
public void UT_PubSub_SubscribeMultipleTypes(RedisContext context)
6060
{
6161
var ch = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -78,7 +78,7 @@ public void UT_PubSub_SubscribeMultipleTypes(RedisContext context)
7878
}
7979
#endif
8080

81-
[Test, TestCaseSource(typeof(Common), "All")]
81+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
8282
public void UT_PubSub_SubscribeWilcards(RedisContext context)
8383
{
8484
var ch = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -113,7 +113,7 @@ public void UT_PubSub_SubscribeWilcards(RedisContext context)
113113
Assert.AreEqual(1, user0count);
114114
}
115115

116-
[Test, TestCaseSource(typeof(Common), "All")]
116+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
117117
public async Task UT_PubSub_SingleSubscribeAsync(RedisContext context)
118118
{
119119
var ch = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -137,7 +137,7 @@ await context.PubSub.SubscribeAsync<User>(ch, (c, o) =>
137137
await context.PubSub.UnsubscribeAsync(ch);
138138
}
139139

140-
[Test, TestCaseSource(typeof(Common), "All")]
140+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
141141
public async Task UT_PubSub_SingleUnsubscribeAsync(RedisContext context)
142142
{
143143
var ch = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -157,7 +157,7 @@ public async Task UT_PubSub_SingleUnsubscribeAsync(RedisContext context)
157157
}
158158

159159
#if (NET462)
160-
[Test, TestCaseSource(typeof(Common), "Bin")]
160+
[Test, TestCaseSource(typeof(Common), nameof(Common.Bin))]
161161
public async Task UT_PubSub_SubscribeMultipleTypesAsync(RedisContext context)
162162
{
163163
var ch = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -180,7 +180,7 @@ public async Task UT_PubSub_SubscribeMultipleTypesAsync(RedisContext context)
180180
}
181181
#endif
182182

183-
[Test, TestCaseSource(typeof(Common), "All")]
183+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
184184
public async Task UT_PubSub_SubscribeWilcardsAsync(RedisContext context)
185185
{
186186
var ch = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";

test/CachingFramework.Redis.UnitTest/UnitTestRedisObjects.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,33 +119,34 @@ public void UT_CacheSet_Mix_WithTags(RedisContext context)
119119
string key = $"UT_CacheSet_Mix_WithTags_Set-{Common.GetUId()}";
120120
string sskey = $"UT_CacheSet_Mix_WithTags_SortedSet-{Common.GetUId()}";
121121
string geokey = $"UT_CacheSet_Mix_WithTags_Geo-{Common.GetUId()}";
122-
context.Cache.InvalidateKeysByTag("tag");
122+
var tag = $"tag-{Common.GetUId()}";
123+
context.Cache.InvalidateKeysByTag(tag);
123124
context.Cache.Remove(key);
124125
context.Cache.Remove(sskey);
125126
var set = context.Collections.GetRedisSet<string>(key);
126127
var sset = context.Collections.GetRedisSortedSet<string>(sskey);
127128
context.GeoSpatial.GeoAdd(geokey, 12.34, 23.45, "geo2");
128-
context.Cache.AddTagsToSetMember(geokey, "geo2", new[] { "tag" });
129+
context.Cache.AddTagsToSetMember(geokey, "geo2", new[] { tag });
129130

130131
set.Add("s1");
131-
set.Add("s2", new[] { "tag" });
132+
set.Add("s2", new[] { tag });
132133
set.Add("s3");
133134

134135
sset.Add(0.1, "ss1");
135136
sset.Add(0.2, "ss2");
136-
context.Cache.AddTagsToSetMember(sskey, "ss2", new[] { "tag" });
137+
context.Cache.AddTagsToSetMember(sskey, "ss2", new[] { tag });
137138
sset.Add(0.3, "ss3");
138139

139-
var x = context.Cache.GetObjectsByTag<string>("tag").ToList();
140+
var x = context.Cache.GetObjectsByTag<string>(tag).ToList();
140141

141142
Assert.AreEqual(3, x.Count);
142143
Assert.IsTrue(x.Contains("geo2"));
143144
Assert.IsTrue(x.Contains("s2"));
144145
Assert.IsTrue(x.Contains("ss2"));
145146

146-
context.Cache.InvalidateKeysByTag("tag");
147+
context.Cache.InvalidateKeysByTag(tag);
147148

148-
x = context.Cache.GetObjectsByTag<string>("tag").ToList();
149+
x = context.Cache.GetObjectsByTag<string>(tag).ToList();
149150
var pos = context.GeoSpatial.GeoPosition(geokey, "geo2");
150151

151152
Assert.AreEqual(0, x.Count);
@@ -1357,7 +1358,7 @@ public void UT_CacheSetObject(RedisContext context)
13571358
Assert.IsNull(user);
13581359
}
13591360

1360-
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
1361+
[Test, TestCaseSource(typeof(Common), nameof(Common.NewtonsoftJson))]
13611362
public void UT_CacheSetObject_TTL(RedisContext context)
13621363
{
13631364
string key1 = $"UT_CacheSetObject_TTL-{Common.GetUId()}";
@@ -1367,7 +1368,7 @@ public void UT_CacheSetObject_TTL(RedisContext context)
13671368
rl.AddRange(users);
13681369
rl.TimeToLive = TimeSpan.FromMilliseconds(1500);
13691370
Assert.AreEqual(users.Count, rl.Count);
1370-
Thread.Sleep(2000);
1371+
Thread.Sleep(4000);
13711372
Assert.AreEqual(0, rl.Count);
13721373
}
13731374

@@ -2148,9 +2149,9 @@ public async Task UT_CacheSetObject_TTLAsync(RedisContext context)
21482149
var users = GetUsers();
21492150
var rl = context.Collections.GetRedisSet<User>(key1);
21502151
await rl.AddRangeAsync(users);
2151-
rl.TimeToLive = TimeSpan.FromMilliseconds(1500);
2152+
rl.TimeToLive = TimeSpan.FromMilliseconds(1000);
21522153
Assert.AreEqual(users.Count, await rl.GetCountAsync());
2153-
Thread.Sleep(2000);
2154+
Thread.Sleep(4000);
21542155
Assert.AreEqual(0, await rl.GetCountAsync());
21552156
}
21562157

test/CachingFramework.Redis.UnitTest/UnitTestRedis_Async.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -916,13 +916,16 @@ public async Task UT_CacheSetWithTags_Multiple_Async(RedisContext context)
916916
await context.Cache.RemoveAsync(key0);
917917
await context.Cache.RemoveAsync(key1);
918918
var users = await GetUsersAsync();
919-
await context.Cache.InvalidateKeysByTagAsync("user:" + users[0].Id, "user:" + users[1].Id, "user-info");
920-
921-
await context.Cache.SetObjectAsync(key0, users[0], new[] { "user:" + users[0].Id, "user-info" });
922-
await context.Cache.SetObjectAsync(key1, users[1], new[] { "user:" + users[1].Id, "user-info" });
923-
var keys0 = await context.Cache.GetKeysByTagAsync(new[] { "user:" + users[0].Id });
924-
var keys1 = await context.Cache.GetKeysByTagAsync(new[] { "user:" + users[1].Id });
925-
var keys = (await context.Cache.GetKeysByTagAsync(new[] { "user-info" })).ToList();
919+
var user0 = $"user:{users[0].Id}-{Common.GetUId()}";
920+
var user1 = $"user:{users[1].Id}-{Common.GetUId()}";
921+
var userInfo = $"user-info-{Common.GetUId()}";
922+
await context.Cache.InvalidateKeysByTagAsync(user0, user1, userInfo);
923+
924+
await context.Cache.SetObjectAsync(key0, users[0], new[] { user0, userInfo });
925+
await context.Cache.SetObjectAsync(key1, users[1], new[] { user1, userInfo });
926+
var keys0 = await context.Cache.GetKeysByTagAsync(new[] { user0 });
927+
var keys1 = await context.Cache.GetKeysByTagAsync(new[] { user0 });
928+
var keys = (await context.Cache.GetKeysByTagAsync(new[] { userInfo })).ToList();
926929
Assert.IsTrue(keys0.Contains(key0));
927930
Assert.IsTrue(keys1.Contains(key1));
928931
Assert.IsTrue(keys.Contains(key0) && keys.Contains(key1));

0 commit comments

Comments
 (0)