public void KeyAlreadyExists() { var source = new List <TestModel>() { new TestModel() { Id = 1, }, new TestModel() { Id = 2, }, new TestModel() { Id = 3, }, }; var target = new Dictionary <int, object>(); target.Add(1, new TestModel() { Id = 1, }); GSrkIDictionaryExtensions.AddRange(target, source, s => s.Id, s => s); }
public void ThrowsIfNullArg3() { List <TestModel> source = new List <TestModel>(); var target = new Dictionary <int, object>(); GSrkIDictionaryExtensions.AddRange(target, source, s => s.Id, null); }
public void Works() { var source = new List <TestModel>() { new TestModel() { Id = 1, }, new TestModel() { Id = 2, }, new TestModel() { Id = 3, }, }; var target = new Dictionary <int, TestModel>(); GSrkIDictionaryExtensions.AddRange(target, source, s => s.Id, s => s); Assert.AreEqual(3, target.Count); Assert.IsTrue(target.ContainsKey(1)); Assert.IsTrue(target.ContainsKey(2)); Assert.IsTrue(target.ContainsKey(3)); Assert.AreSame(source[0], target[1]); Assert.AreSame(source[1], target[2]); Assert.AreSame(source[2], target[3]); }
public void ThrowsIfNullArg0() { List <TestModel> source = new List <TestModel>(); Dictionary <int, object> target = null; GSrkIDictionaryExtensions.AddRange(target, source, s => s.Id, s => s.Name); }