public void IndexerFiltersDuplicatesWhenNotAllowed() { const string Value = "test value"; const string OtherValue = "other value"; var dict = new MultivalueDictionary<int, string>( () => new HashSet<string>() ); dict[1] = new[] { Value, OtherValue, Value }; Assert.Equal( dict.CountValues( 1 ), 2 ); }
public void SetRangeShouldFilterDuplicatesWhenNotAllowed() { const string Value = "test value"; const string OtherValue = "other value"; var dict = new MultivalueDictionary<int, string>( () => new HashSet<string>() ); dict.Add( 1, Value ); dict.Add( 1, OtherValue ); Assert.Equal( dict.CountValues( 1 ), 2 ); dict.SetRange( 1, new[] { Value, Value } ); Assert.Equal( dict.CountValues( 1 ), 1 ); Assert.Equal( dict[1].First(), Value ); }
public void SetRangeShouldReplaceValues() { const string Value = "test value"; const string OtherValue = "other value"; var dict = new MultivalueDictionary<int, string>( () => new HashSet<string>() ); dict.Add( 1, Value ); dict.Add( 1, OtherValue ); Assert.Equal( dict.CountValues( 1 ), 2 ); dict.SetRange( 1, new[] { Guid.NewGuid().ToString() } ); Assert.Equal( dict.CountValues( 1 ), 1 ); }
public void RemoveShouldRemoveValues() { const string Value = "test value"; const string OtherValue = "other value"; var dict = new MultivalueDictionary<int, string>( () => new HashSet<string>() ); dict.Add( 1, Value ); dict.Add( 2, OtherValue ); Assert.Equal( dict.Count, 2 ); Assert.Equal( dict.CountValues( 1 ), 1 ); Assert.Equal( dict.CountValues( 2 ), 1 ); dict.Remove( 1 ); Assert.Equal( dict.Count, 1 ); Assert.Equal( dict.CountValues( 2 ), 1 ); Assert.False( dict.Remove( 2, Value ) ); Assert.True( dict.Remove( 2, OtherValue ) ); }
public void CountValuesShouldReturnCorrectNumber() { const string Value = "test value"; const string OtherValue = "other value"; var dict = new MultivalueDictionary<int, string>(); dict.Add( 1, Value ); dict.Add( 1, OtherValue ); dict.Add( 2, OtherValue ); Assert.Equal( 2, dict.CountValues( 1 ) ); }