public void TryGetValue_ShouldNotGetValueWhenValueIsDefaultUserDefinedStruct() { var distributedCacheMock = new Mock <IDistributedCache>(); distributedCacheMock.Setup(c => c.Get(It.IsAny <string>())) .Returns((byte[])null) .Verifiable(); var cache = new DistributedFlow(distributedCacheMock.Object); var isSuccess = cache.TryGetValue("key", out DefaultStruct result); Assert.False(isSuccess); Assert.Equal(default, result);
public void TryGetValue_ShouldNotGetValueWhenValueIsNull() { var distributedCacheMock = new Mock <IDistributedCache>(); distributedCacheMock.Setup(c => c.Get(It.IsAny <string>())) .Returns((byte[])null) .Verifiable(); var cache = new DistributedFlow(distributedCacheMock.Object); var result = cache.TryGetValue <object>("key", out _); Assert.False(result); distributedCacheMock.Verify(c => c.Get(It.IsAny <string>()), Times.Once); }