Example #1
0
            public void WhenSerializableTypeThenBytesAreSet()
            {
                SerializableTestClass testClass = new SerializableTestClass {
                    Name = "serializable-test-xxx"
                };

                byte[] expected = testClass.ToByteArray();

                _distributedCache.Set <SerializableTestClass>("serializable-test", testClass);

                _mockDistributedCache.Verify(
                    dc => dc.Set(
                        "serializable-test",
                        It.Is <byte[]>(actual => VerifyBytes(expected, actual)),
                        It.IsAny <DistributedCacheEntryOptions>()));
            }
Example #2
0
            public async Task WhenSerializableTypeThenBytesAreSetAsync()
            {
                SerializableTestClass testClass = new SerializableTestClass {
                    Name = "serializable-test-xxx"
                };

                byte[] expected = testClass.ToByteArray();

                await _distributedCache.SetAsync <SerializableTestClass>("serializable-test", testClass);

                _mockDistributedCache.Verify(
                    dc => dc.SetAsync(
                        "serializable-test",
                        It.Is <byte[]>(actual => VerifyBytes(expected, actual)),
                        It.IsAny <DistributedCacheEntryOptions>(),
                        It.IsAny <CancellationToken>()));
            }