public void Touch_ExistingDocNoExpiration_RemovesExpiration()
        {
            // Arrange

            var clockProvider = new LambdaClockProvider(() => new DateTime(2000, 1, 1));

            var bucket = new MockBucket(clockProvider)
            {
                { "key", new MockDocument
                  {
                      Cas        = 100,
                      Content    = new object(),
                      Expiration = new DateTime(2000, 1, 2)
                  } }
            };

            // Act

            var result = bucket.Touch("key", TimeSpan.Zero);

            // Assert

            Assert.True(result.Success);
            Assert.Equal(ResponseStatus.Success, result.Status);

            Assert.True(bucket.TryGetMock("key", out var mockDocument));
            Assert.Null(mockDocument.Expiration);
        }
        public void Touch_ExistingDocWithExpiration_SetsExpiration()
        {
            // Arrange

            var clockProvider = new LambdaClockProvider(() => new DateTime(2000, 1, 1));

            var bucket = new MockBucket(clockProvider)
            {
                { "key", new MockDocument
                  {
                      Cas        = 100,
                      Content    = new object(),
                      Expiration = new DateTime(2000, 1, 2)
                  } }
            };

            // Act

            var result = bucket.Touch("key", TimeSpan.FromMinutes(1));

            // Assert

            Assert.True(result.Success);
            Assert.Equal(ResponseStatus.Success, result.Status);

            Assert.True(bucket.TryGetMock("key", out var mockDocument));
            Assert.NotNull(mockDocument.Expiration);
            Assert.Equal(clockProvider.GetCurrentDateTime().AddMinutes(1), mockDocument.Expiration.Value);
        }
        public void Touch_MissingDoc_KeyNotFound(IEnumerable <KeyValuePair <string, MockDocument> > documents)
        {
            // Arrange

            // Will ensure sample doc above on 1/1/2000 is expired
            var clockProvider = new LambdaClockProvider(() => new DateTime(2000, 1, 2));

            var bucket = new MockBucket(clockProvider);

            bucket.AddRange(documents);

            // Act

            var result = bucket.Touch("key", TimeSpan.FromMinutes(1));

            // Assert

            Assert.False(result.Success);
            Assert.Equal(ResponseStatus.KeyNotFound, result.Status);
        }