Ejemplo n.º 1
0
    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);
    }
Ejemplo n.º 2
0
    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);
    }