public void Set_ShouldSetValueWhenValueIsDefaultPrimitiveStruct() { var distributedCacheMock = new Mock <IDistributedCache>(); distributedCacheMock.Setup(c => c.Set(It.IsAny <string>(), It.IsAny <byte[]>(), It.IsAny <DistributedCacheEntryOptions>())) .Verifiable(); var cache = new DistributedFlow(distributedCacheMock.Object); cache.Set("Key", default(int), TimeSpan.MaxValue); distributedCacheMock .Verify(c => c.Set(It.IsAny <string>(), It.IsAny <byte[]>(), It.IsAny <DistributedCacheEntryOptions>()), Times.Once); }
public void Set_ShouldNotSetValueWhenValueIsDefaultUserDefinedStruct() { var distributedCacheMock = new Mock <IDistributedCache>(); distributedCacheMock.Setup(c => c.Set(It.IsAny <string>(), It.IsAny <byte[]>(), It.IsAny <DistributedCacheEntryOptions>())) .Verifiable(); var cache = new DistributedFlow(distributedCacheMock.Object); cache.Set("Key", new DefaultStruct(0), TimeSpan.MaxValue); distributedCacheMock.Verify( c => c.Set(It.IsAny <string>(), It.IsAny <byte[]>(), It.IsAny <DistributedCacheEntryOptions>()), Times.Never); }