public void Remove_NonExistingKey_Fails() { // Arrange var nameKey = "Name"; var dictionary = new Dictionary <string, object>(StringComparer.Ordinal); var dictionaryAdapter = new DictionaryAdapter <string, object>(); var resolver = new DefaultContractResolver(); // Act var removeStatus = dictionaryAdapter.TryRemove(dictionary, nameKey, resolver, out var message); // Assert Assert.False(removeStatus); Assert.Equal("The target location specified by path segment 'Name' was not found.", message); Assert.Empty(dictionary); }
public void Remove_NonExistingKey_Fails() { // Arrange var nameKey = "Name"; var dictionary = new Dictionary <string, object>(StringComparer.Ordinal); var dictionaryAdapter = new DictionaryAdapter <string, object>(); var options = new JsonSerializerOptions(); // Act var removeStatus = dictionaryAdapter.TryRemove(dictionary, typeof(Dictionary <string, object>), nameKey, options, out var message); // Assert Assert.False(removeStatus); Assert.Equal("The target location specified by path segment 'Name' was not found.", message); Assert.Empty(dictionary); }
public void Remove_RemovesFromDictionary_WithUriKey() { // Arrange var uriKey = new Uri("http://www.test.com/name"); var dictionary = new Dictionary <Uri, object>(); dictionary[uriKey] = "James"; var dictionaryAdapter = new DictionaryAdapter <Uri, object>(); var resolver = new DefaultContractResolver(); // Act var removeStatus = dictionaryAdapter.TryRemove(dictionary, uriKey.ToString(), resolver, out var message); //Assert Assert.True(removeStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Empty(dictionary); }
public void Remove_RemovesFromDictionary() { // Arrange var nameKey = "Name"; var dictionary = new Dictionary <string, object>(StringComparer.Ordinal); dictionary[nameKey] = "James"; var dictionaryAdapter = new DictionaryAdapter <string, object>(); var resolver = new DefaultContractResolver(); // Act var removeStatus = dictionaryAdapter.TryRemove(dictionary, nameKey, resolver, out var message); //Assert Assert.True(removeStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Empty(dictionary); }
public void Remove_RemovesFromDictionary_WithUriKey() { // Arrange var uriKey = new Uri("http://www.test.com/name"); var dictionary = new Dictionary <Uri, object> { [uriKey] = "James" }; var dictionaryAdapter = new DictionaryAdapter <Uri, object>(); var options = new JsonSerializerOptions(); // Act var removeStatus = dictionaryAdapter.TryRemove(dictionary, typeof(Dictionary <Uri, object>), uriKey.ToString(), options, out var message); //Assert Assert.True(removeStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Empty(dictionary); }
public void Remove_RemovesFromDictionary() { // Arrange var nameKey = "Name"; var dictionary = new Dictionary <string, object>(StringComparer.Ordinal) { [nameKey] = "James" }; var dictionaryAdapter = new DictionaryAdapter <string, object>(); var options = new JsonSerializerOptions(); // Act var removeStatus = dictionaryAdapter.TryRemove(dictionary, typeof(Dictionary <string, object>), nameKey, options, out var message); //Assert Assert.True(removeStatus); Assert.True(string.IsNullOrEmpty(message), "Expected no error message"); Assert.Empty(dictionary); }