public void Remove_EmptyStringIsAllowed() { // Arrange var dict = new AdaptiveCapacityDictionary <string, string>(); // Act var result = dict.Remove(""); // Assert Assert.False(result); }
public void Remove_KeyAndOutValue_EmptyStringIsAllowed() { // Arrange var dict = new AdaptiveCapacityDictionary <string, string>(); // Act var result = dict.Remove("", out var removedValue); // Assert Assert.False(result); Assert.Null(removedValue); }
public void Remove_ListStorage_True_CaseInsensitive() { // Arrange var dict = new AdaptiveCapacityDictionary <string, object>(StringComparer.OrdinalIgnoreCase) { { "key", "value" }, }; // Act var result = dict.Remove("kEy"); // Assert Assert.True(result); Assert.Empty(dict); Assert.IsType <KeyValuePair <string, object?>[]>(dict._arrayStorage); }
public void Remove_ListStorage_False() { // Arrange var dict = new AdaptiveCapacityDictionary <string, object>() { { "key", "value" }, }; // Act var result = dict.Remove("other"); // Assert Assert.False(result); Assert.Collection(dict, kvp => { Assert.Equal("key", kvp.Key); Assert.Equal("value", kvp.Value); }); Assert.IsType <KeyValuePair <string, object?>[]>(dict._arrayStorage); }
public void Remove_KeyAndOutValue_ListStorage_True() { // Arrange object value = "value"; var dict = new AdaptiveCapacityDictionary <string, object>() { { "key", value } }; // Act var result = dict.Remove("key", out var removedValue); // Assert Assert.True(result); Assert.Same(value, removedValue); Assert.Empty(dict); Assert.IsType <KeyValuePair <string, object?>[]>(dict._arrayStorage); }
public void Remove_KeyAndOutValue_ListStorage_KeyExists_Last() { // Arrange object value = "value"; var dict = new AdaptiveCapacityDictionary <string, object>() { { "other", 5 }, { "dotnet", "rocks" }, { "key", value } }; // Act var result = dict.Remove("key", out var removedValue); // Assert Assert.True(result); Assert.Same(value, removedValue); Assert.Equal(2, dict.Count); Assert.False(dict.ContainsKey("key")); Assert.True(dict.ContainsKey("other")); Assert.True(dict.ContainsKey("dotnet")); Assert.IsType <KeyValuePair <string, object?>[]>(dict._arrayStorage); }