public void GetBySecondFact(string secondValue, string firstValue, bool expectedResult)
        {
            var results = _dictionary.GetBySecond(secondValue);

            var result = results.ToList().Contains(firstValue);

            result.Should().Be(expectedResult);
        }
Beispiel #2
0
        public void TestBidirectionalDictionary()
        {
            var dict1 = new BidirectionalDictionary <int, double>();

            dict1.Add(4, 2.0);
            Assert.IsTrue(dict1.ContainsFirst(4) && dict1.ContainsSecond(2));
            bool exceptionOnDuplicate = false;

            try {
                dict1.Add(4, 3.0);
            }
            catch (ArgumentException) { exceptionOnDuplicate = true; }
            Assert.IsTrue(exceptionOnDuplicate);
            Assert.IsTrue(dict1.GetByFirst(4) == 2);
            Assert.IsTrue(dict1.GetBySecond(2) == 4);
            Assert.IsTrue(dict1.Count == 1);
            dict1.Clear();
            Assert.IsTrue(dict1.Count == 0);

            var dict2 = new BidirectionalDictionary <ComplexType, int>(new ComplexTypeEqualityComparer());

            Assert.IsTrue(!dict2.Any());
            dict2.Add(new ComplexType(1), 2);
            Assert.IsTrue(dict2.Any());
            dict2.Add(new ComplexType(2), 1);
            Assert.IsTrue(dict2.ContainsFirst(new ComplexType(2)));
            Assert.IsTrue(dict2.ContainsSecond(2));
            exceptionOnDuplicate = false;
            try {
                dict2.Add(new ComplexType(2), 3);
            }
            catch (ArgumentException) { exceptionOnDuplicate = true; }
            Assert.IsTrue(exceptionOnDuplicate);
            exceptionOnDuplicate = false;
            try {
                dict2.Add(new ComplexType(3), 1);
            }
            catch (ArgumentException) { exceptionOnDuplicate = true; }
            Assert.IsTrue(exceptionOnDuplicate);
            Assert.IsTrue(dict2.Count == 2);
            Assert.IsTrue(dict2.GetBySecond(1).Field == 2);
            Assert.IsTrue(dict2.GetByFirst(new ComplexType(1)) == 2);
            dict2.Clear();
            Assert.IsTrue(!dict2.Any());
        }
Beispiel #3
0
        private void graphVisualization_OnEntityRemoved(object sender, EntityEventArgs e)
        {
            IShape shape = e.Entity as IShape;

            if (shape != null && this.shapeInfoShapeMapping.ContainsSecond(shape))
            {
                IShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(shape);
                this.Content.RemoveShapeInfo(shapeInfo);
            }

            IConnection connection = e.Entity as IConnection;

            if (connection != null && this.connectionInfoConnectionMapping.ContainsSecond(connection))
            {
                IConnectionInfo connectionInfo = connectionInfoConnectionMapping.GetBySecond(connection);
                this.Content.RemoveConnectionInfo(connectionInfo);
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public string Get(SqlDbType type)
 {
     return(_typeMap.GetBySecond(type).FirstOrDefault());
 }