コード例 #1
0
        public void ContainsTest()
        {
            var dic = new ObservableDictionary <int, string>();

            dic.Contains(new KeyValuePair <int, string>(1, null)).Should().BeFalse();
            dic.Add(1, "1"); dic.Add(2, "2");
            dic.Contains(new KeyValuePair <int, string>(1, "1")).Should().BeTrue();
        }
コード例 #2
0
            public void ContainsObjectInvalidTypeFalse()
            {
                var observableDictionary = new ObservableDictionary <int, int>()
                {
                    {
                        1, 2
                    }
                };

                var result = observableDictionary.Contains((object)"1");

                Assert.IsFalse(result);
            }
コード例 #3
0
            public void ContainsObjectTrue()
            {
                var observableDictionary = new ObservableDictionary <int, int>()
                {
                    {
                        1, 2
                    }
                };

                var result = observableDictionary.Contains((object)1);

                Assert.IsTrue(result);
            }
コード例 #4
0
            public void ContainsKvpSuccess()
            {
                var observableDictionary = new ObservableDictionary <int, int>()
                {
                    {
                        1, 2
                    }
                };

                var result = observableDictionary.Contains(new KeyValuePair <int, int>(1, 2));

                Assert.IsTrue(result);
            }
コード例 #5
0
        public void ObservableDictionaryContainsTest()
        {
            ObservableDictionary<GenericParameterHelper, GenericParameterHelper> target = new ObservableDictionary<GenericParameterHelper, GenericParameterHelper>();
            KeyValuePair<GenericParameterHelper, GenericParameterHelper> itemAdded = new KeyValuePair<GenericParameterHelper, GenericParameterHelper>(new GenericParameterHelper(1), new GenericParameterHelper(1));
            KeyValuePair<GenericParameterHelper, GenericParameterHelper> itemNotAdded = new KeyValuePair<GenericParameterHelper, GenericParameterHelper>(new GenericParameterHelper(2), new GenericParameterHelper(2));
            target.Add(itemAdded);

            bool expectedAdded = true;
            bool expectedNotAdded = false;
            bool actualAdded = target.Contains(itemAdded);
            bool actualNotAdded = target.Contains(itemNotAdded);

            Assert.AreEqual(expectedAdded, actualAdded);
            Assert.AreEqual(expectedNotAdded, actualNotAdded);
        }