public void TryToUpdate_KeyValueExistButValueHasChangedInStore_AddFails() { // Arrange var oldHash = InMemoryKeyValueStore.GetMmd5Hash("changed-value"); _inMemoryStore.InMemoryStore.TryAdd("existing-key", new HashedValue <object> { Value = "changed-value", Hash = oldHash }); // Act var addResult = _inMemoryStore.TrySetValue("existing-key", "new-value", "different-hash"); // Assert addResult.Should().Be(false); _inMemoryStore.InMemoryStore.Should().NotBeNull(); _inMemoryStore.InMemoryStore.Keys.Should().Contain(k => k == "existing-key"); _inMemoryStore.InMemoryStore["existing-key"].Value.Should().Be("changed-value"); }
public void TryToUpdate_KeyValueExistInStore_AddSuccessful() { // Arrange var oldHash = InMemoryKeyValueStore.GetMmd5Hash("existing-value"); _inMemoryStore.InMemoryStore.TryAdd("existing-key", new HashedValue <object> { Value = "existing-value", Hash = oldHash }); // Act var addResult = _inMemoryStore.TrySetValue("existing-key", "new-value", oldHash); // Assert addResult.Should().Be(true); _inMemoryStore.InMemoryStore.Should().NotBeNull(); _inMemoryStore.InMemoryStore.Keys.Should().Contain(k => k == "existing-key"); _inMemoryStore.InMemoryStore["existing-key"].Value.Should().Be("new-value"); }