Skip to content

Commit 5c82211

Browse files
Federico ColomboFederico Colombo
authored andcommitted
fixing unit tests
1 parent d34e482 commit 5c82211

File tree

3 files changed

+168
-168
lines changed

3 files changed

+168
-168
lines changed

test/CachingFramework.Redis.UnitTest/UnitTestRedis.cs

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public void UT_CustomTagPostfix(RedisContext ctx)
125125
Assert.AreEqual(key, tagSetMembers[0].ToString());
126126
}
127127

128-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
128+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
129129
public void UT_CustomTagPrefixPostfix(RedisContext ctx)
130130
{
131131
// Arrange
@@ -193,7 +193,7 @@ public void UT_KeyTaggedTTL(RedisContext ctx)
193193
Assert.AreEqual("the value", value);
194194
}
195195

196-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
196+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
197197
public void UT_MultipleAddHashedWithTags(RedisContext ctx)
198198
{
199199
var key = $"{TestContext.CurrentContext.Test.MethodName}-{ctx.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -223,7 +223,7 @@ public void UT_MultipleAddHashedWithTags(RedisContext ctx)
223223
Assert.AreEqual("3three", ser.Deserialize<string>(members0[2].MemberValue));
224224
}
225225

226-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
226+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
227227
public void UT_HashedWithFieldTypes(RedisContext ctx)
228228
{
229229
var key = $"{TestContext.CurrentContext.Test.MethodName}-{ctx.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -251,7 +251,7 @@ public void UT_HashedWithFieldTypes(RedisContext ctx)
251251
}
252252

253253

254-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
254+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
255255
public void UT_SetGetHashedMultiple(RedisContext ctx)
256256
{
257257
var key = $"{TestContext.CurrentContext.Test.MethodName}-{ctx.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -266,7 +266,7 @@ public void UT_SetGetHashedMultiple(RedisContext ctx)
266266
Assert.AreEqual(10, result[3]);
267267
}
268268

269-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
269+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
270270
public void UT_SetGetHashedMultiple_Generic(RedisContext ctx)
271271
{
272272
var key = $"{TestContext.CurrentContext.Test.MethodName}-{ctx.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -305,7 +305,7 @@ public void UT_DefaultSerializer(RedisContext context)
305305
RedisContext.DefaultSerializer = prev;
306306
}
307307

308-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
308+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
309309
public void UT_Cache_MembersByTag(RedisContext context)
310310
{
311311
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -366,7 +366,7 @@ public void UT_Cache_MembersByTag(RedisContext context)
366366
context.Cache.InvalidateKeysByTag(tag1, tag2);
367367
}
368368

369-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
369+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
370370
public void UT_Cache_IsOnTagMethods(RedisContext context)
371371
{
372372
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -423,7 +423,7 @@ public void UT_Cache_IsOnTagMethods(RedisContext context)
423423
context.Cache.InvalidateKeysByTag(tag1, tag2);
424424
}
425425

426-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
426+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
427427
public void UT_Cache_SetHashed_TK_TV(RedisContext context)
428428
{
429429
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -440,7 +440,7 @@ public void UT_Cache_SetHashed_TK_TV(RedisContext context)
440440
Assert.AreEqual(users[1].Id, u1.Id);
441441
}
442442

443-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
443+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
444444
public void UT_Cache_SetHashed_TK_TV_WithTags(RedisContext context)
445445
{
446446
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -477,7 +477,7 @@ public void UT_Cache_SetHashed_TK_TV_WithTags(RedisContext context)
477477
Assert.AreEqual(users[1].Id, dict[users[0]].Id);
478478
}
479479

480-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
480+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
481481
public void UT_Cache_Hash_Scan(RedisContext context)
482482
{
483483
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -666,7 +666,7 @@ public void UT_CacheSerializer(RedisContext context)
666666
kch, kds, kdt, kby, ksby, ki16, ki32, kdbl });
667667
}
668668

669-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
669+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
670670
public void UT_Cache_GetAllTags(RedisContext context)
671671
{
672672
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -676,7 +676,7 @@ public void UT_Cache_GetAllTags(RedisContext context)
676676
Assert.IsTrue(tags.Contains("tag2"));
677677
}
678678

679-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
679+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
680680
public void UT_Cache_GetKeysByPattern(RedisContext context)
681681
{
682682
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -712,7 +712,7 @@ public void UT_Cache_RawOverrideSerializer()
712712
Assert.AreEqual(users[0].Id, v3);
713713
}
714714

715-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
715+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
716716
public void UT_CacheByteArray(RedisContext context)
717717
{
718718
context.Cache.SetObject("key", "jpeg");
@@ -729,7 +729,7 @@ public void UT_CacheByteArray(RedisContext context)
729729
Assert.IsTrue(Enumerable.SequenceEqual(jpeg.Data, jpeg2.Data));
730730
}
731731

732-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
732+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
733733
public void UT_CacheAddGet(RedisContext context)
734734
{
735735
// Test the Add and Get methods
@@ -744,7 +744,7 @@ public void UT_CacheAddGet(RedisContext context)
744744
Assert.AreEqual("one", user.Deparments[0].Location.Name);
745745
}
746746

747-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
747+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
748748
public void UT_CacheFetch(RedisContext context)
749749
{
750750
// Test the Fetch method
@@ -758,7 +758,7 @@ public void UT_CacheFetch(RedisContext context)
758758
Assert.AreEqual(a[0].Id, b[0].Id);
759759
}
760760

761-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
761+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
762762
public void UT_CacheFetch_TTL(RedisContext context)
763763
{
764764
// Test the Fetch method
@@ -773,7 +773,7 @@ public void UT_CacheFetch_TTL(RedisContext context)
773773
Assert.AreEqual(2, count);
774774
}
775775

776-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
776+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
777777
public void UT_CacheFetchHashed(RedisContext context)
778778
{
779779
// Test the FetchHashed method
@@ -786,7 +786,7 @@ public void UT_CacheFetchHashed(RedisContext context)
786786
Assert.AreEqual(users[0].Id, returnedUser2.Id);
787787
}
788788

789-
[Test, TestCaseSource(typeof (Common), nameof(Common.All))]
789+
[Test, TestCaseSource(typeof (Common), nameof(Common.Json))]
790790
public void UT_CacheFetch_Nulls(RedisContext context)
791791
{
792792
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -796,7 +796,7 @@ public void UT_CacheFetch_Nulls(RedisContext context)
796796
Assert.IsFalse(context.Cache.KeyExists(key));
797797
}
798798

799-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
799+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
800800
public void UT_CacheFetchHashed_Nulls(RedisContext context)
801801
{
802802
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -806,7 +806,7 @@ public void UT_CacheFetchHashed_Nulls(RedisContext context)
806806
Assert.IsFalse(context.Cache.KeyExists(key));
807807
}
808808

809-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
809+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
810810
public void UT_CacheTryGetObject(RedisContext context)
811811
{
812812
// Test the TryGetObject method
@@ -823,7 +823,7 @@ public void UT_CacheTryGetObject(RedisContext context)
823823
Assert.IsNotNull(u1);
824824
}
825825

826-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
826+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
827827
public void UT_CacheTryGetHashed(RedisContext context)
828828
{
829829
// Test the TryGetHashed method
@@ -840,7 +840,7 @@ public void UT_CacheTryGetHashed(RedisContext context)
840840
Assert.IsNotNull(u1);
841841
}
842842

843-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
843+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
844844
public void UT_CacheGetSetObject(RedisContext context)
845845
{
846846
// Test the GetSetObject method
@@ -861,7 +861,7 @@ public void UT_CacheGetSetObject(RedisContext context)
861861
Assert.AreEqual(2, integer);
862862
}
863863

864-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
864+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
865865
public void UT_CacheGetHashAll(RedisContext context)
866866
{
867867
// Test the GetHashAll method
@@ -879,7 +879,7 @@ public void UT_CacheGetHashAll(RedisContext context)
879879
Assert.AreEqual(2, dict["2"].Id);
880880
}
881881

882-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
882+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
883883
public void UT_CacheRemove(RedisContext context)
884884
{
885885
// Test the Remove method
@@ -897,7 +897,7 @@ public void UT_CacheRemove(RedisContext context)
897897
Assert.IsNull(returnedUser);
898898
}
899899

900-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
900+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
901901
public void UT_CacheRemoveMultiple(RedisContext context)
902902
{
903903
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -916,7 +916,7 @@ public void UT_CacheRemoveMultiple(RedisContext context)
916916
}
917917
}
918918

919-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
919+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
920920
public void UT_CacheRemoveHashed(RedisContext context)
921921
{
922922
// Test the Remove method for a complete hash set
@@ -941,7 +941,7 @@ public void UT_CacheRemoveHashed(RedisContext context)
941941
Assert.AreEqual(2, returnedUser2.Id);
942942
}
943943

944-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
944+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
945945
public void UT_CacheRemove_PreviouslyHashed(RedisContext context)
946946
{
947947
// Test the Remove hashed method
@@ -966,7 +966,7 @@ public void UT_CacheRemove_PreviouslyHashed(RedisContext context)
966966
Assert.IsNull(returnedUser2);
967967
}
968968

969-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
969+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
970970
public void UT_CacheAdd_Expiration(RedisContext context)
971971
{
972972
// Test the expiration of the Add method
@@ -983,7 +983,7 @@ public void UT_CacheAdd_Expiration(RedisContext context)
983983
Assert.IsNull(user);
984984
}
985985

986-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
986+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
987987
public void UT_CacheAddHashed_Expiration_1(RedisContext context)
988988
{
989989
// Test the expiration of the AddHashed method (MAX ttl applies)
@@ -1001,7 +1001,7 @@ public void UT_CacheAddHashed_Expiration_1(RedisContext context)
10011001
Assert.IsNotNull(user2);
10021002
}
10031003

1004-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1004+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
10051005
public void UT_CacheAddHashed_Expiration_2(RedisContext context)
10061006
{
10071007
// Test the expiration of the Fetch method (last larger expiration applies)
@@ -1019,7 +1019,7 @@ public void UT_CacheAddHashed_Expiration_2(RedisContext context)
10191019
Assert.IsNotNull(user2);
10201020
}
10211021

1022-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1022+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
10231023
public void UT_CacheAddHashed_Expiration_3(RedisContext context)
10241024
{
10251025
// Test the expiration of the Fetch method (last no-expiration applies)
@@ -1051,7 +1051,7 @@ public void UT_CacheSetHashed_KeyTimeToLive(RedisContext context)
10511051
Assert.IsTrue(ttl.Value.Seconds >= 8);
10521052
}
10531053

1054-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1054+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
10551055
public void UT_CacheSetHashed_Tags(RedisContext context)
10561056
{
10571057
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -1113,7 +1113,7 @@ public void UT_CacheFetchHashed_Tags(RedisContext context)
11131113
Assert.AreEqual(users[1].Id, u.Id);
11141114
}
11151115

1116-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1116+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
11171117
public void UT_CacheSetWithTags_Default(RedisContext context)
11181118
{
11191119
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -1126,7 +1126,7 @@ public void UT_CacheSetWithTags_Default(RedisContext context)
11261126
Assert.IsNotNull(value);
11271127
}
11281128

1129-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1129+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
11301130
public void UT_CacheFetchWithTags(RedisContext context)
11311131
{
11321132
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -1143,7 +1143,7 @@ public void UT_CacheFetchWithTags(RedisContext context)
11431143
Assert.IsFalse(keys.Contains(key));
11441144
}
11451145

1146-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1146+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
11471147
public void UT_CacheSetWithTags_PersistentOverridesExpiration(RedisContext context)
11481148
{
11491149
var key1 = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -1152,7 +1152,7 @@ public void UT_CacheSetWithTags_PersistentOverridesExpiration(RedisContext conte
11521152
context.Cache.InvalidateKeysByTag(tag);
11531153
context.Cache.SetObject(key1, "test value 1", new[] { tag }, TimeSpan.FromSeconds(1));
11541154
context.Cache.SetObject(key2, "test value 2", new[] { tag }, TimeSpan.MaxValue);
1155-
Thread.Sleep(2000);
1155+
Thread.Sleep(4000);
11561156
var keys = context.Cache.GetKeysByTag(new[] { tag }).ToList();
11571157
var keysCleaned = context.Cache.GetKeysByTag(new[] { tag }, true).ToList();
11581158
Assert.AreEqual(2, keys.Count);
@@ -1164,7 +1164,7 @@ public void UT_CacheSetWithTags_PersistentOverridesExpiration(RedisContext conte
11641164
}
11651165

11661166

1167-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1167+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
11681168
public void UT_CacheSetWithTags_Expiration(RedisContext context)
11691169
{
11701170
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -1199,7 +1199,7 @@ public void UT_CacheSetWithTags_Expiration(RedisContext context)
11991199
Assert.IsTrue(keys3.Contains(key2));
12001200
}
12011201

1202-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1202+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
12031203
public void UT_CacheSetWithTags_Removal(RedisContext context)
12041204
{
12051205
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -1217,7 +1217,7 @@ public void UT_CacheSetWithTags_Removal(RedisContext context)
12171217
Assert.IsFalse(keys2.Contains(key));
12181218
}
12191219

1220-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1220+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
12211221
public void UT_CacheSetWithTags_Multiple(RedisContext context)
12221222
{
12231223
var key0 = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-0-{Common.GetUId()}";
@@ -1240,7 +1240,7 @@ public void UT_CacheSetWithTags_Multiple(RedisContext context)
12401240
Assert.IsTrue(keys.Contains(key0) && keys.Contains(key1));
12411241
}
12421242

1243-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1243+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
12441244
public void UT_CacheRemoveByTags(RedisContext context)
12451245
{
12461246
var key1 = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-1-{Common.GetUId()}";
@@ -1260,7 +1260,7 @@ public void UT_CacheRemoveByTags(RedisContext context)
12601260
Assert.AreEqual(0, keys.Count());
12611261
}
12621262

1263-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1263+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
12641264
public void UT_CacheGetObjectsByTag(RedisContext context)
12651265
{
12661266
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}" + "{0}";
@@ -1288,7 +1288,7 @@ public void UT_CacheGetObjectsByTag(RedisContext context)
12881288
Assert.IsNull(context.Cache.GetObject<User>(string.Format(key, 1)));
12891289
}
12901290

1291-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1291+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
12921292
public void UT_CacheAddRemoveTagToKey(RedisContext context)
12931293
{
12941294
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -1304,7 +1304,7 @@ public void UT_CacheAddRemoveTagToKey(RedisContext context)
13041304

13051305
}
13061306

1307-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1307+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
13081308
public void UT_CacheSetHashedAll(RedisContext context)
13091309
{
13101310
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";
@@ -1317,7 +1317,7 @@ public void UT_CacheSetHashedAll(RedisContext context)
13171317
Assert.IsTrue(users.All(x => response.ContainsKey(x.Id.ToString())));
13181318
}
13191319

1320-
[Test, TestCaseSource(typeof(Common), nameof(Common.All))]
1320+
[Test, TestCaseSource(typeof(Common), nameof(Common.Json))]
13211321
public void UT_Cache_HllAddCount(RedisContext context)
13221322
{
13231323
var key = $"{TestContext.CurrentContext.Test.MethodName}-{context.GetSerializer().GetType().Name}-{Common.GetUId()}";

0 commit comments

Comments
 (0)