public void TryAddBijectionTest() { var bijective = new Bijective <string, int>(); bijective["A"] = 10; Assert.IsFalse(bijective.TryAddBijection("A", 10)); Assert.IsFalse(bijective.TryAddBijection("B", 10)); Assert.IsFalse(bijective.TryAddBijection("A", 20)); Assert.IsTrue(bijective.TryAddBijection("B", 20)); Assert.IsTrue(bijective.LeftElementExists("B")); Assert.IsTrue(bijective.RightElementExists(20)); var allLeftElementsList = new List <string>(bijective.GetAllLeftElements()); Assert.AreEqual(2, allLeftElementsList.Count); Assert.IsTrue(allLeftElementsList.Contains("B")); var allRightElementsList = new List <int>(bijective.GetAllRightElements()); Assert.AreEqual(2, allRightElementsList.Count); Assert.IsTrue(allRightElementsList.Contains(20)); Assert.IsFalse(bijective.CanAddBijection("B", 20)); Assert.IsFalse(bijective.CanAddReverseBijection(20, "B")); Tuple <string, int> bijection; Assert.IsTrue(bijective.TryGetBijection("B", out bijection)); Assert.AreEqual("B", bijection.Item1); Assert.AreEqual(20, bijection.Item2); Tuple <int, string> reverseBijection; Assert.IsTrue(bijective.TryGetReverseBijection(20, out reverseBijection)); Assert.AreEqual(20, reverseBijection.Item1); Assert.AreEqual("B", reverseBijection.Item2); var allBijectionsList = new List <Tuple <string, int> >(bijective.GetAllBijections()); Assert.AreEqual(2, allBijectionsList.Count); Assert.IsTrue(allBijectionsList.Select(b => b.Item1).Contains("B")); Assert.IsTrue(allBijectionsList.Select(b => b.Item2).Contains(20)); var allReverseBijectionsList = new List <Tuple <int, string> >(bijective.GetAllReverseBijections()); Assert.AreEqual(2, allReverseBijectionsList.Count); Assert.IsTrue(allReverseBijectionsList.Select(b => b.Item1).Contains(20)); Assert.IsTrue(allReverseBijectionsList.Select(b => b.Item2).Contains("B")); }