public void AddToDictionaryFromCollection_NonEmptyDictionaryAndListWithNonUniqueKeysNotFromSourceDictionary_ReturnsInvalidRecordListAndCorrectDictionary()
        {
            var item = new ObjectWithKey(3, "Three");
            var dict = new Dictionary<int, ObjectWithKey> { { item.Key, item } };
            var list = new List<ObjectWithKey> { new ObjectWithKey(1, "One"), new ObjectWithKey(2, "Two"), new ObjectWithKey(2, "Two") };
            var invalid = new List<ObjectWithKey>();
            CollectionTools.AddToDictionaryFromCollection(dict, list, invalid, o => o.Key);

            Assert.AreEqual(2, dict.Count);
            Assert.AreEqual(2, invalid.Count);
        }
Esempio n. 2
0
        public void AddToDictionaryFromCollection_NonEmptyDictionaryAndListWithNonUniqueKeysNotFromSourceDictionary_ReturnsInvalidRecordListAndCorrectDictionary()
        {
            var item = new ObjectWithKey(3, "Three");
            var dict = new Dictionary <int, ObjectWithKey> {
                { item.Key, item }
            };
            var list = new List <ObjectWithKey> {
                new ObjectWithKey(1, "One"), new ObjectWithKey(2, "Two"), new ObjectWithKey(2, "Two")
            };
            var invalid = new List <ObjectWithKey>();

            CollectionTools.AddToDictionaryFromCollection(dict, list, invalid, o => o.Key);

            Assert.AreEqual(2, dict.Count);
            Assert.AreEqual(2, invalid.Count);
        }