public async Task GetOrDefaultAsync_WithMissingKey_ReturnsDefault() { // Arrange var cache = CreateDistributedCache(); var dic = new DistributedDictionary <Guid, TestPerson>(cache, new OptionsWrapper <DistributedDictionaryOptions>(new DistributedDictionaryOptions())); var key = Guid.Parse("054392d5-1a51-4f8a-96c7-2a3eb0db2842"); // Act var result = await dic.GetOrDefaultAsync(key); // Assert Assert.Null(result); }
public async Task GetOrDefaultAsync_WithDefaultOptions_ReturnsCorrectObject() { // Arrange var cache = CreateDistributedCache(); await cache.SetAsync("testhost:SimpleConcepts.DistributedDictionary.Tests.TestPerson:054392d5-1a51-4f8a-96c7-2a3eb0db2842", new byte[] { 123, 34, 78, 97, 109, 101, 34, 58, 34, 82, 97, 112, 104, 97, 101, 108, 34, 44, 34, 65, 103, 101, 34, 58, 51, 49, 125 }); var dic = new DistributedDictionary <Guid, TestPerson>(cache, new OptionsWrapper <DistributedDictionaryOptions>(new DistributedDictionaryOptions())); var key = Guid.Parse("054392d5-1a51-4f8a-96c7-2a3eb0db2842"); // Act var result = await dic.GetOrDefaultAsync(key); // Assert Assert.Equal("Raphael", result.Name); Assert.Equal(31, result.Age); }