public void Try_simulate_NRE_when_calling_GetAllEntriesFromHash_using_BasicRedisClientManager() { using (var redisManager = new BasicRedisClientManager(TestConfig.SingleHost)) using (var redis = redisManager.GetClient()) { IRedisHash <string, Test> testHash = redis.As <Test>() .GetHash <string>("test-hash"); Assert.That(testHash.Count, Is.EqualTo(0)); var contents = testHash.GetAll(); Assert.That(contents.Count, Is.EqualTo(0)); var test1 = new Test { Id = 1, Name = "Name1" }; var test2 = new Test { Id = 2, Name = "Name2" }; testHash["A"] = test1; testHash["B"] = test2; contents = testHash.GetAll(); Assert.That(contents, Is.EqualTo(new Dictionary <string, Test> { ["A"] = test1, ["B"] = test2, })); Assert.That(testHash["A"], Is.EqualTo(test1)); Assert.That(testHash["B"], Is.EqualTo(test2)); } }
static void ListAllWords(IRedisHash <String, String> collection) { var dict = collection.GetAll(); Console.WriteLine("----------------------------"); Console.WriteLine("Words in Dictionary:"); Console.WriteLine("----------------------------"); foreach (var entry in dict) { Console.WriteLine(entry.Key + ": " + entry.Value); } ; Console.WriteLine("----------------------------"); }