public void Upsert_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.Upsert("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 Upsert_NewDoc_KeyNotFound() { // Arrange var bucket = new MockBucket(); // Act var result = bucket.Upsert("key", new object()); // Assert Assert.True(result.Success); Assert.Equal(ResponseStatus.Success, result.Status); Assert.True(bucket.ContainsMock("key")); }
public void Upsert_ExistingDoc_IncrementsCas() { // Arrange var bucket = new MockBucket { { "key", new object() } }; Assert.True(bucket.TryGetMock("key", out var mockDocument)); var originalCas = mockDocument.Cas; // Act bucket.Upsert("key", new object()); // Assert Assert.True(bucket.TryGetMock("key", out mockDocument)); Assert.True(mockDocument.Cas > originalCas); }
public void Upsert_ExistingDoc_Overwrites() { // Arrange var bucket = new MockBucket { { "key", new object() } }; var newObject = new object(); // Act var result = bucket.Upsert("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); }