コード例 #1
0
        public void Remove_DifferentCas_CasMismatch()
        {
            // Arrange

            var existingObject = new object();
            var bucket         = new MockBucket
            {
                { "key", existingObject }
            };

            Assert.True(bucket.TryGetMock("key", out var mockDocument));
            var originalCas = mockDocument.Cas;

            // Act

            var result = bucket.Remove("key", originalCas - 1);

            // Assert

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

            Assert.True(bucket.TryGetMock("key", out mockDocument));
            Assert.Equal(existingObject, mockDocument?.Content);
        }
コード例 #2
0
        public void Remove_NewDoc_KeyNotFound()
        {
            // Arrange

            var bucket = new MockBucket();

            // Act

            var result = bucket.Remove("key");

            // Assert

            Assert.False(result.Success);
            Assert.Equal(ResponseStatus.KeyNotFound, result.Status);
        }
コード例 #3
0
        public void Remove_ExistingDoc_Removes()
        {
            // Arrange

            var bucket = new MockBucket
            {
                { "key", new object() }
            };

            // Act

            var result = bucket.Remove("key");

            // Assert

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

            Assert.False(bucket.TryGetMock("key", out _));
        }