public void Replace_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.Replace("key", new object(), 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); }
public void Replace_NewDoc_KeyNotFound() { // Arrange var bucket = new MockBucket(); // Act var result = bucket.Replace("key", new object()); // Assert Assert.False(result.Success); Assert.Equal(ResponseStatus.KeyNotFound, result.Status); }
public void Replace_ExistingDoc_IncrementsCas() { // Arrange var bucket = new MockBucket { { "key", new object() } }; Assert.True(bucket.TryGetMock("key", out var mockDocument)); var originalCas = mockDocument.Cas; // Act bucket.Replace("key", new object()); // Assert Assert.True(bucket.TryGetMock("key", out mockDocument)); Assert.True(mockDocument.Cas > originalCas); }
public void Replace_ExistingDoc_Overwrites() { // Arrange var bucket = new MockBucket { { "key", new object() } }; var newObject = new object(); // Act var result = bucket.Replace("key", newObject); // Assert Assert.True(result.Success); Assert.Equal(ResponseStatus.Success, result.Status); Assert.True(bucket.TryGetMock("key", out var mockDocument)); Assert.Equal(newObject, mockDocument?.Content); }