Example #1
0
        public void ShouldAddNoItems()
        {
            var source = new List <int> {
                1, 2, 3
            };
            var initial = source.ToList();

            CollectionExtensions.AddRange(source, Enumerable.Empty <int>());

            CollectionAssert.AreEqual(source, initial);
        }
Example #2
0
 public void ShouldThrowWhenNoSourceSpecified()
 {
     try
     {
         CollectionExtensions.AddRange(null, new int[] { 1, 2, 3 });
         Assert.Fail("Allowed to invoke from null");
     }
     catch (Exception ex)
     {
         Assert.IsInstanceOfType(ex, typeof(ArgumentNullException));
         Assert.AreEqual("collection", ((ArgumentNullException)ex).ParamName);
     }
 }
Example #3
0
        public void ShouldAddItems()
        {
            var source = new List <int> {
                1, 2, 3
            };
            var add = new List <int> {
                4, 5, 6
            };

            CollectionExtensions.AddRange(source, add);

            CollectionAssert.IsSubsetOf(add, source);
        }
Example #4
0
        public void ShouldThrowWhenNoCollectionToAddSpecified()
        {
            var source = new List <int> {
                1, 2, 3
            };

            try
            {
                CollectionExtensions.AddRange(source, null);
                Assert.Fail("Allowed to add from null");
            }
            catch (Exception ex)
            {
                Assert.IsInstanceOfType(ex, typeof(ArgumentNullException));
                Assert.AreEqual("items", ((ArgumentNullException)ex).ParamName);
            }
        }