From f4641c352ee426b9551742ac8b5c2a3a20cbd5bb Mon Sep 17 00:00:00 2001 From: Rohan Edman Date: Sat, 4 Feb 2023 20:03:21 -0500 Subject: [PATCH 1/3] Update RedisObjectHandler.cs Fixed type casting issue for https://github.com/redis/redis-om-dotnet/issues/286 --- src/Redis.OM/RedisObjectHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Redis.OM/RedisObjectHandler.cs b/src/Redis.OM/RedisObjectHandler.cs index ed6ee434..092167cd 100644 --- a/src/Redis.OM/RedisObjectHandler.cs +++ b/src/Redis.OM/RedisObjectHandler.cs @@ -262,7 +262,7 @@ internal static string SetId(this object obj) } else { - idProperty.SetValue(obj, id); + idProperty.SetValue(obj, Convert.ChangeType(id, idProperty.PropertyType)); } } } From 06c449e8616cfc974fcd80a9238d68d0e90c2e44 Mon Sep 17 00:00:00 2001 From: Rohan Edman Date: Sun, 5 Feb 2023 12:42:27 -0500 Subject: [PATCH 2/3] Fixed update to nul collectoin --- .../Modeling/RedisCollectionStateManager.cs | 11 +++++----- .../RediSearchTests/SearchFunctionalTests.cs | 20 +++++++++++++++++++ .../RedisJsonNestedComposeValueTest.cs | 2 +- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/Redis.OM/Modeling/RedisCollectionStateManager.cs b/src/Redis.OM/Modeling/RedisCollectionStateManager.cs index a1ff3a4a..6223e6a0 100644 --- a/src/Redis.OM/Modeling/RedisCollectionStateManager.cs +++ b/src/Redis.OM/Modeling/RedisCollectionStateManager.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Text.Json; using System.Text.Json.Serialization; +using System.Xml; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Redis.OM; @@ -122,7 +123,7 @@ internal bool TryDetectDifferencesSingle(string key, object value, out IList(dataJson, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var snapshot = (JToken)Snapshot[key]; var diff = FindDiff(current!, snapshot); - differences = BuildJsonDifference(diff, "$"); + differences = BuildJsonDifference(diff, "$", snapshot); } else { @@ -157,7 +158,7 @@ internal IDictionary> DetectDifferences() var current = JsonConvert.DeserializeObject(dataJson, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); var snapshot = (JToken)Snapshot[key]; var diff = FindDiff(current!, snapshot); - var diffArgs = BuildJsonDifference(diff, "$"); + var diffArgs = BuildJsonDifference(diff, "$", snapshot); res.Add(key, diffArgs); } else @@ -193,7 +194,7 @@ internal IDictionary> DetectDifferences() return res; } - private static IList BuildJsonDifference(JObject diff, string currentPath) + private static IList BuildJsonDifference(JObject diff, string currentPath, JToken snapshot) { var ret = new List(); if (diff.ContainsKey("+") && diff.ContainsKey("-")) @@ -215,7 +216,7 @@ private static IList BuildJsonDifference(JObject diff, string curre if (diff.ContainsKey("+")) { - if (diff["+"] is JArray arr) + if (diff["+"] is JArray arr && snapshot.SelectToken(diff.Path) is not null) { ret.AddRange(arr.Select(item => new JsonDiff("ARRAPPEND", currentPath, item))); } @@ -244,7 +245,7 @@ private static IList BuildJsonDifference(JObject diff, string curre foreach (var item in diff) { var val = item.Value as JObject; - ret.AddRange(BuildJsonDifference(val!, $"{currentPath}.{item.Key}")); + ret.AddRange(BuildJsonDifference(val!, $"{currentPath}.{item.Key}", snapshot)); } return ret; diff --git a/test/Redis.OM.Unit.Tests/RediSearchTests/SearchFunctionalTests.cs b/test/Redis.OM.Unit.Tests/RediSearchTests/SearchFunctionalTests.cs index 6382c9b0..c38830d2 100644 --- a/test/Redis.OM.Unit.Tests/RediSearchTests/SearchFunctionalTests.cs +++ b/test/Redis.OM.Unit.Tests/RediSearchTests/SearchFunctionalTests.cs @@ -350,6 +350,26 @@ public void TestUpdate() Assert.Equal(testP.Id, secondQueriedP.Id); } + + [Fact] + public void TestUpdateNullCollection() + { + var nickNames = new List() { "Bond", "James", "Steve" }; + var collection = new RedisCollection(_connection); + var testP = new Person { Name = "Steve", Age = 32 }; + var key = collection.Insert(testP); + var queriedP = collection.FindById(key); + + queriedP.NickNamesList = nickNames; + collection.Update(queriedP); + + var secondQueriedP = collection.FindById(key); + + Assert.NotNull(secondQueriedP); + Assert.Equal(secondQueriedP.NickNamesList, nickNames); + + } + [Fact] public async Task TestUpdateAsync() { diff --git a/test/Redis.OM.Unit.Tests/SearchJsonTests/RedisJsonNestedComposeValueTest.cs b/test/Redis.OM.Unit.Tests/SearchJsonTests/RedisJsonNestedComposeValueTest.cs index 2a5b6a46..827d19b5 100644 --- a/test/Redis.OM.Unit.Tests/SearchJsonTests/RedisJsonNestedComposeValueTest.cs +++ b/test/Redis.OM.Unit.Tests/SearchJsonTests/RedisJsonNestedComposeValueTest.cs @@ -92,7 +92,7 @@ public async Task TestEmbeddedMultipleListWithUpdate() } [Fact] - public async Task TestEmbeddedMultipleListWithUpdateInsert() + public void TestEmbeddedMultipleListWithUpdateInsert() { var currentAddress = new Address { State = "KL", City = "Kozhikode" }; var permanentAddress = new Address { State = "TN", City = "Salem" }; From 922681a009fdf1d3929c1bf87947a33ce0b231fb Mon Sep 17 00:00:00 2001 From: Rohan Edman Date: Wed, 8 Feb 2023 18:45:10 -0500 Subject: [PATCH 3/3] fixed test due tu concurence --- .../RediSearchTests/SearchFunctionalTests.cs | 145 ++++++++---------- 1 file changed, 66 insertions(+), 79 deletions(-) diff --git a/test/Redis.OM.Unit.Tests/RediSearchTests/SearchFunctionalTests.cs b/test/Redis.OM.Unit.Tests/RediSearchTests/SearchFunctionalTests.cs index 79c221ab..f60bef81 100644 --- a/test/Redis.OM.Unit.Tests/RediSearchTests/SearchFunctionalTests.cs +++ b/test/Redis.OM.Unit.Tests/RediSearchTests/SearchFunctionalTests.cs @@ -17,13 +17,13 @@ namespace Redis.OM.Unit.Tests.RediSearchTests [Collection("Redis")] public class SearchFunctionalTests { - public SearchFunctionalTests(RedisSetup setup) { _connection = setup.Connection; Setup().Wait(); SetupHashModel().Wait(); } + private IRedisConnection _connection = null; private async Task SetupHashModel() @@ -48,8 +48,6 @@ private async Task SetupHashModel() await Task.WhenAll(tasks); } - - private async Task Setup() { var names = new[] { "Steve", "Sarah", "Chris", "Theresa", "Frank", "Mary", "John", "Alice", "Bob" }; @@ -83,7 +81,6 @@ public void EnumerateAllRecords() i++; } Assert.True(i >= 500); - } [Fact] @@ -123,17 +120,17 @@ public void TestLimit() public void TestFirstOrDefault() { var collection = new RedisCollection(_connection); - collection.Insert(new Person{Name = "John"}); + collection.Insert(new Person { Name = "John" }); var firstJohn = collection.FirstOrDefault(x => x.Name == "John"); Assert.NotNull(firstJohn); - Assert.Equal("John",firstJohn.Name); + Assert.Equal("John", firstJohn.Name); } [Fact] public void TestAny() { var collection = new RedisCollection(_connection); - collection.Insert(new Person{Name = "John"}); + collection.Insert(new Person { Name = "John" }); var anyJohn = collection.Any(x => x.Name == "John"); Assert.True(anyJohn); } @@ -142,7 +139,7 @@ public void TestAny() public void TestBasicQuerySpecialCharacters() { var collection = new RedisCollection(_connection); - collection.Insert(new Person{Name = "Bond, James Bond", Email = "james.bond@sis.gov.uk", TagField = "James Bond"}); + collection.Insert(new Person { Name = "Bond, James Bond", Email = "james.bond@sis.gov.uk", TagField = "James Bond" }); var anyBond = collection.Any(x => x.Name == "Bond, James Bond" && x.Email == "james.bond@sis.gov.uk" && x.TagField == "James Bond"); Assert.True(anyBond); } @@ -150,13 +147,13 @@ public void TestBasicQuerySpecialCharacters() [Fact] public void TestSave() { - var collection = new RedisCollection(_connection,10000); + var collection = new RedisCollection(_connection, 10000); var count = 0; foreach (var person in collection) { count++; person.Name = "TestSave"; - person.Mother = new Person {Name = "Diane"}; + person.Mother = new Person { Name = "Diane" }; } collection.Save(); @@ -169,11 +166,11 @@ public async Task TestSaveAsync() { var collection = new RedisCollection(_connection); var count = 0; - await foreach (var person in collection.Where(x=>x.Name == "Chris")) + await foreach (var person in collection.Where(x => x.Name == "Chris")) { count++; person.Name = "TestSaveAsync"; - person.Mother = new Person {Name = "Monica"}; + person.Mother = new Person { Name = "Monica" }; person.IsEngineer = true; } await collection.SaveAsync(); @@ -183,7 +180,6 @@ public async Task TestSaveAsync() } [Fact] - public async Task TestSaveAsyncSecondEnumeration() { var collection = new RedisCollection(_connection); @@ -198,7 +194,6 @@ public async Task TestSaveAsyncSecondEnumeration() await collection.SaveAsync(); var augustines = collection.Where(x => x.Name == "TestSaveAsyncSecondEnumeration"); Assert.Equal(count, augustines.Count()); - } [Fact] @@ -210,7 +205,7 @@ public async Task TestSaveHashAsync() { count++; person.Name = "TestSaveHashAsync"; - person.Mother = new HashPerson {Name = "Diane"}; + person.Mother = new HashPerson { Name = "Diane" }; } await collection.SaveAsync(); var steves = collection.Where(x => x.Name == "TestSaveHashAsync"); @@ -238,19 +233,17 @@ public void TestSaveArray() Assert.Equal(maryNicknames.ToArray(), mary.NickNames); } } - catch(Exception) + catch (Exception) { throw; } - - } [Fact] public void TestSaveArrayHash() { - var maryNicknames = new List {"Mary", "Mae", "Mimi", "Mitzi"}; - var maria = new HashPerson {Name = "Maria", NickNames = maryNicknames}; + var maryNicknames = new List { "Mary", "Mae", "Mimi", "Mitzi" }; + var maria = new HashPerson { Name = "Maria", NickNames = maryNicknames }; _connection.Set(maria); maryNicknames.RemoveAt(1); maryNicknames.RemoveAt(1); @@ -264,24 +257,23 @@ public void TestSaveArrayHash() { Assert.Equal(maryNicknames.ToArray(), mary.NickNames); } - } [Fact] public void TestSetGetWithLoc() { - var testP = new Person {Name = "Steve", Home = new GeoLoc(1.0, 1.0)}; - var id =_connection.Set(testP); + var testP = new Person { Name = "Steve", Home = new GeoLoc(1.0, 1.0) }; + var id = _connection.Set(testP); var reconstituded = _connection.Get(id); Assert.Equal("Steve", reconstituded.Name); - Assert.Equal(new GeoLoc(1.0,1.0), reconstituded.Home); + Assert.Equal(new GeoLoc(1.0, 1.0), reconstituded.Home); } [Fact] public void TestNestedObjectQuery() { - var testP = new Person{Name = "Steve", Home = new GeoLoc(1.0, 1.0), Address = new Address{ City = "Newark"}}; - var id =_connection.Set(testP); + var testP = new Person { Name = "Steve", Home = new GeoLoc(1.0, 1.0), Address = new Address { City = "Newark" } }; + var id = _connection.Set(testP); var collection = new RedisCollection(_connection); Assert.True(collection.Where(x => x.Name == "Steve" && x.Address.City == "Newark").FirstOrDefault() != default); } @@ -289,7 +281,7 @@ public void TestNestedObjectQuery() [Fact] public void TestNestedObjectQuery2Levels() { - var testP = new Person{Name = "Steve", Home = new GeoLoc(1.0, 1.0), Address = new Address{ ForwardingAddress = new Address{City = "Newark"}}}; + var testP = new Person { Name = "Steve", Home = new GeoLoc(1.0, 1.0), Address = new Address { ForwardingAddress = new Address { City = "Newark" } } }; var id = _connection.Set(testP); var collection = new RedisCollection(_connection); Assert.True(collection.Where(x => x.Name == "Steve" && x.Address.ForwardingAddress.City == "Newark").FirstOrDefault() != default); @@ -298,7 +290,7 @@ public void TestNestedObjectQuery2Levels() [Fact] public void TestArrayQuery() { - var testP = new Person{Name = "Stephen", Home = new GeoLoc(1.0, 1.0), Address = new Address{ ForwardingAddress = new Address{City = "Newark"}}, NickNames = new []{"Steve"}}; + var testP = new Person { Name = "Stephen", Home = new GeoLoc(1.0, 1.0), Address = new Address { ForwardingAddress = new Address { City = "Newark" } }, NickNames = new[] { "Steve" } }; var id = _connection.Set(testP); var collection = new RedisCollection(_connection); var steve = collection.FirstOrDefault(x => x.NickNames.Contains("Steve")); @@ -308,7 +300,7 @@ public void TestArrayQuery() [Fact] public void TestArrayQuerySpecialChars() { - var testP = new Person{Name = "Stephen", Home = new GeoLoc(1.0, 1.0), Address = new Address{ ForwardingAddress = new Address{City = "Newark"}}, NickNames = new []{"Steve@redis.com"}}; + var testP = new Person { Name = "Stephen", Home = new GeoLoc(1.0, 1.0), Address = new Address { ForwardingAddress = new Address { City = "Newark" } }, NickNames = new[] { "Steve@redis.com" } }; var id = _connection.Set(testP); var collection = new RedisCollection(_connection); var steve = collection.FirstOrDefault(x => x.NickNames.Contains("Steve@redis.com")); @@ -318,10 +310,10 @@ public void TestArrayQuerySpecialChars() [Fact] public void TestListQuery() { - var testP = new Person{Name = "Stephen", Home = new GeoLoc(1.0, 1.0), Address = new Address{ ForwardingAddress = new Address{City = "Newark"}}, NickNamesList = new List {"Steve"}}; + var testP = new Person { Name = "Stephen", Home = new GeoLoc(1.0, 1.0), Address = new Address { ForwardingAddress = new Address { City = "Newark" } }, NickNamesList = new List { "Stevie" } }; var id = _connection.Set(testP); var collection = new RedisCollection(_connection); - var steve = collection.FirstOrDefault(x => x.NickNamesList.Contains("Steve")); + var steve = collection.FirstOrDefault(x => x.NickNamesList.Contains("Stevie")); Assert.Equal(id.Split(':')[1], steve.Id); } @@ -330,14 +322,14 @@ public void TestCountWithEmptyCollection() { var collection = new RedisCollection(_connection); var count = collection.Count(); - Assert.Equal(0,count); + Assert.Equal(0, count); } [Fact] public void TestUpdate() { var collection = new RedisCollection(_connection); - var testP = new Person {Name = "Steve", Age = 32}; + var testP = new Person { Name = "Steve", Age = 32 }; var key = collection.Insert(testP); var queriedP = collection.FindById(key); Assert.NotNull(queriedP); @@ -352,16 +344,15 @@ public void TestUpdate() Assert.Equal(testP.Id, secondQueriedP.Id); } - [Fact] public void TestUpdateNullCollection() { - var nickNames = new List() { "Bond", "James", "Steve" }; + var nickNames = new List() { "Bond", "James", "Steve" }; var collection = new RedisCollection(_connection); var testP = new Person { Name = "Steve", Age = 32 }; var key = collection.Insert(testP); var queriedP = collection.FindById(key); - + queriedP.NickNamesList = nickNames; collection.Update(queriedP); @@ -369,14 +360,13 @@ public void TestUpdateNullCollection() Assert.NotNull(secondQueriedP); Assert.Equal(secondQueriedP.NickNamesList, nickNames); - } [Fact] public async Task TestUpdateAsync() { var collection = new RedisCollection(_connection); - var testP = new Person {Name = "Steve", Age = 32}; + var testP = new Person { Name = "Steve", Age = 32 }; var key = await collection.InsertAsync(testP); var queriedP = await collection.FindByIdAsync(key); Assert.NotNull(queriedP); @@ -395,7 +385,7 @@ public async Task TestUpdateAsync() public async Task TestUpdateName() { var collection = new RedisCollection(_connection); - var testP = new Person {Name = "Steve", Age = 32}; + var testP = new Person { Name = "Steve", Age = 32 }; var key = await collection.InsertAsync(testP); var id = testP.Id; var queriedP = collection.First(x => x.Id == id); @@ -415,7 +405,7 @@ public async Task TestUpdateName() public async Task TestUpdateHashPerson() { var collection = new RedisCollection(_connection); - var testP = new HashPerson {Name = "Steve", Age = 32}; + var testP = new HashPerson { Name = "Steve", Age = 32 }; var key = await collection.InsertAsync(testP); var queriedP = await collection.FindByIdAsync(key); Assert.NotNull(queriedP); @@ -433,7 +423,7 @@ public async Task TestUpdateHashPerson() [Fact] public async Task TestToListAsync() { - var collection = new RedisCollection(_connection,10000); + var collection = new RedisCollection(_connection, 10000); var list = await collection.ToListAsync(); Assert.Equal(collection.Count(), list.Count); @@ -450,29 +440,28 @@ public async Task CountAsync() [Fact] public async Task TestFirstOrDefaultAsync() { - var collection = new RedisCollection(_connection,10000); + var collection = new RedisCollection(_connection, 10000); Assert.NotNull(await collection.FirstOrDefaultAsync()); } [Fact] public async Task TestAnyAsync() { - var collection = new RedisCollection(_connection,10000); + var collection = new RedisCollection(_connection, 10000); Assert.True(await collection.AnyAsync()); } [Fact] public async Task TestSingleAsync() { - var person = new Person {Name = "foo"}; - var collection = new RedisCollection(_connection,10000); + var person = new Person { Name = "foo" }; + var collection = new RedisCollection(_connection, 10000); await collection.InsertAsync(person); var id = person.Id; var res = await collection.SingleAsync(x => x.Id == id); - Assert.Equal("foo",res.Name); + Assert.Equal("foo", res.Name); } - [Fact] public async Task TestNonExistentPersonJson() { @@ -506,23 +495,23 @@ public async Task TestNonExistentHashPersonGet() [Fact] public async Task FindByIdAsync() { - var person = new Person {Name = "Bob"}; + var person = new Person { Name = "Bob" }; var collection = new RedisCollection(_connection); await collection.InsertAsync(person); var alsoBob = await collection.FindByIdAsync(person.Id); Assert.NotNull(alsoBob); - Assert.Equal("Bob",person.Name); + Assert.Equal("Bob", person.Name); } [Fact] public void FindById() { - var person = new Person {Name = "Bob"}; + var person = new Person { Name = "Bob" }; var collection = new RedisCollection(_connection); collection.Insert(person); var alsoBob = collection.FindById(person.Id); Assert.NotNull(alsoBob); - Assert.Equal("Bob",person.Name); + Assert.Equal("Bob", person.Name); } [Fact] @@ -546,23 +535,23 @@ public void FindByIdSavedToStateManager() [Fact] public void FindByKey() { - var person = new Person {Name = "Bob"}; + var person = new Person { Name = "Bob" }; var collection = new RedisCollection(_connection); var key = collection.Insert(person); var alsoBob = collection.FindById(key); Assert.NotNull(alsoBob); - Assert.Equal("Bob",person.Name); + Assert.Equal("Bob", person.Name); } [Fact] public async Task FindByKeyAsync() { - var person = new Person {Name = "Bob"}; + var person = new Person { Name = "Bob" }; var collection = new RedisCollection(_connection); var key = await collection.InsertAsync(person); var alsoBob = await collection.FindByIdAsync(key); Assert.NotNull(alsoBob); - Assert.Equal("Bob",person.Name); + Assert.Equal("Bob", person.Name); } [Fact] @@ -612,7 +601,7 @@ public async Task SearchByBooleanFalse() [Fact] public async Task TestSearchByStringEnum() { - var obj = new ObjectWithStringLikeValueTypes() {AnEnum = AnEnum.two, AnEnumAsInt = AnEnum.three}; + var obj = new ObjectWithStringLikeValueTypes() { AnEnum = AnEnum.two, AnEnumAsInt = AnEnum.three }; await _connection.SetAsync(obj); var anEnum = AnEnum.two; var three = AnEnum.three; @@ -638,7 +627,7 @@ public async Task TestSearchByStringEnum() [Fact] public async Task TestSearchByStringEnumHash() { - var obj = new ObjectWithStringLikeValueTypesHash() {AnEnum = AnEnum.two}; + var obj = new ObjectWithStringLikeValueTypesHash() { AnEnum = AnEnum.two }; await _connection.SetAsync(obj); var anEnum = AnEnum.two; var collection = new RedisCollection(_connection); @@ -660,8 +649,8 @@ public async Task TestAnySearchEmbeddedObjects() { Name = "Bob", Numeric = 100, - Addresses = new[] {new Address {City = "Newark", State = "New Jersey"}}, - AddressList = new List
{new() {City = "Satellite Beach", State = "Florida"}} + Addresses = new[] { new Address { City = "Newark", State = "New Jersey" } }, + AddressList = new List
{ new() { City = "Satellite Beach", State = "Florida" } } }; await _connection.SetAsync(obj); @@ -688,21 +677,20 @@ public async Task TestQueryWithNoStopwords() var result = await collection.FirstOrDefaultAsync(x => x.Name == "to be or not to be that is the question"); Assert.NotNull(result); - } [Fact] public async Task FindByIdsAsyncIds() { - var person1 = new Person() {Name = "Alice", Age = 51}; - var person2 = new Person() {Name = "Bob", Age = 37}; + var person1 = new Person() { Name = "Alice", Age = 51 }; + var person2 = new Person() { Name = "Bob", Age = 37 }; var collection = new RedisCollection(_connection); await collection.InsertAsync(person1); await collection.InsertAsync(person2); - var ids = new string[] {person1.Id, person2.Id}; + var ids = new string[] { person1.Id, person2.Id }; var people = await collection.FindByIdsAsync(ids); Assert.NotNull(people[ids[0]]); @@ -719,15 +707,15 @@ public async Task FindByIdsAsyncIds() [Fact] public async Task FindByIdsAsyncIdsWithDuplicatedIds() { - var person1 = new Person() {Name = "Alice", Age = 51}; - var person2 = new Person() {Name = "Bob", Age = 37}; + var person1 = new Person() { Name = "Alice", Age = 51 }; + var person2 = new Person() { Name = "Bob", Age = 37 }; var collection = new RedisCollection(_connection); await collection.InsertAsync(person1); await collection.InsertAsync(person2); - var ids = new string[] {person1.Id, person2.Id, person1.Id, person2.Id}; + var ids = new string[] { person1.Id, person2.Id, person1.Id, person2.Id }; var people = await collection.FindByIdsAsync(ids); Assert.NotNull(people[ids[0]]); @@ -744,15 +732,15 @@ public async Task FindByIdsAsyncIdsWithDuplicatedIds() [Fact] public async Task FindByIdsAsyncKeys() { - var person1 = new Person() {Name = "Alice", Age = 51}; - var person2 = new Person() {Name = "Bob", Age = 37}; + var person1 = new Person() { Name = "Alice", Age = 51 }; + var person2 = new Person() { Name = "Bob", Age = 37 }; var collection = new RedisCollection(_connection); var key1 = await collection.InsertAsync(person1); var key2 = await collection.InsertAsync(person2); - var keys = new string[] {key1, key2}; + var keys = new string[] { key1, key2 }; var people = await collection.FindByIdsAsync(keys); Assert.NotNull(people[keys[0]]); @@ -847,16 +835,16 @@ public async Task TestSaveAfterAsyncMethods() public async Task TestMultipleContains() { var collection = new RedisCollection(_connection); - var person1 = new Person() {Name = "Alice", Age = 51, NickNames = new []{"Ally","Alie","Al"}}; - var person2 = new Person() {Name = "Robert", Age = 37, NickNames = new []{"Bobby", "Rob", "Bob"}}; + var person1 = new Person() { Name = "Alice", Age = 51, NickNames = new[] { "Ally", "Alie", "Al" } }; + var person2 = new Person() { Name = "Robert", Age = 37, NickNames = new[] { "Bobby", "Rob", "Bob" } }; await collection.InsertAsync(person1); await collection.InsertAsync(person2); var people = await collection.Where(x => x.NickNames.Contains("Bob") || x.NickNames.Contains("Alie")).ToListAsync(); - - Assert.Contains(people, x =>x.Id == person1.Id); - Assert.Contains(people, x =>x.Id == person2.Id); + + Assert.Contains(people, x => x.Id == person1.Id); + Assert.Contains(people, x => x.Id == person2.Id); } [Fact] @@ -884,7 +872,7 @@ public async Task TestShouldFailForSave() var collection = new RedisCollection(_connection, false, 100); var ex = await Assert.ThrowsAsync(collection.SaveAsync().AsTask); Assert.Equal(expectedText, ex.Message); - ex = Assert.Throws(() =>collection.Save()); + ex = Assert.Throws(() => collection.Save()); Assert.Equal(expectedText, ex.Message); } @@ -894,11 +882,10 @@ public async Task TestStatelessCollection() var collection = new RedisCollection(_connection, false, 10000); var res = await collection.ToListAsync(); Assert.True(res.Count >= 1); - Assert.Equal(0,collection.StateManager.Data.Count); - Assert.Equal(0,collection.StateManager.Snapshot.Count); + Assert.Equal(0, collection.StateManager.Data.Count); + Assert.Equal(0, collection.StateManager.Snapshot.Count); } - [Fact] public async Task TestFlagEnumQuery() { @@ -969,7 +956,7 @@ public async Task TestListContains() public async Task TestListMultipleContains() { var collection = new RedisCollection(_connection); - var person1 = new Person() { Name = "Ferb", Age = 14, NickNames = new[] { "Feb", "Fee" }, TagField = "Ferb" }; + var person1 = new Person() { Name = "Ferb", Age = 14, NickNames = new[] { "Feb", "Fee" }, TagField = "Ferb" }; var person2 = new Person() { Name = "Phineas", Age = 14, NickNames = new[] { "Phineas", "Triangle Head", "Phine" }, TagField = "Phineas" }; await collection.InsertAsync(person1);