public void RemovePairTest() { var bijection = new Bijection <int, string> { { 1, "a" }, { 2, "b" }, { 3, "c" } }; Assert.Equal(1, bijection["a", TagRight.Value]); Assert.Equal(2, bijection["b", TagRight.Value]); Assert.Equal(3, bijection["c", TagRight.Value]); Assert.Equal("a", bijection[1]); Assert.Equal("b", bijection[2]); Assert.Equal("c", bijection[3]); bijection.Remove(KeyValuePair.Create(2, "b")); bijection.Remove(KeyValuePair.Create(1, "x")); Assert.Equal(1, bijection["a", TagRight.Value]); Assert.Equal(3, bijection["c", TagRight.Value]); Assert.Equal("a", bijection[1]); Assert.Equal("c", bijection[3]); Assert.False(bijection.ContainsKey(2)); Assert.False(bijection.ContainsRightKey("b")); bijection.Remove(1); bijection.Remove(3); Assert.Empty(bijection); bijection.Remove(KeyValuePair.Create(1, "a")); }
public void ContainsKeyTest() { var bijection = new Bijection <int, string> { { 1, "a" }, { 2, "b" }, { 3, "c" } }; Assert.True(bijection.ContainsKey(2)); Assert.False(bijection.ContainsKey(4)); Assert.True(bijection.ContainsRightKey("b")); Assert.False(bijection.ContainsRightKey("d")); bijection[5] = "e"; Assert.True(bijection.ContainsKey(5)); Assert.True(bijection.ContainsRightKey("e")); }