public void TestCollateWithComaparerByNullCollectionsThrowsException()
        {
            var students1 = CollectionsMockBuilder.GetValidStudentsList();
            var students2 = new List <Student>
            {
                new Student()
                {
                    Name = "AA", Age = 17, ClassName = "SSC"
                },
                new Student()
                {
                    Name = "BB", Age = 23, ClassName = "SSC"
                },
                new Student()
                {
                    Name = "CC", Age = 14, ClassName = "SSC"
                }
            };

            Assert.Throws <ArgumentNullException>(
                () => CollectionUtils.Collate(null, students2, new StudentComparer(), false));
            Assert.Throws <ArgumentNullException>(
                () => CollectionUtils.Collate(students1, null, new StudentComparer(), false));
            Assert.Throws <ArgumentException>(() => CollectionUtils.Collate(students1, students2, null, false));
        }
        public void TestIsEqualCollectionWithPredicateSuccess()
        {
            var coll1 = new List <string> {
                "Satish", "KK"
            };
            var coll2 = new List <string> {
                "KK", "Satish"
            };
            var std1 = CollectionsMockBuilder.GetValidStudentsList();
            var std2 = new List <Student>
            {
                new Student()
                {
                    Name = "satish", Age = 10, ClassName = "SSC"
                },
                new Student()
                {
                    Name = "kumar", Age = 11, ClassName = "SSC"
                },
                new Student()
                {
                    Name = "rama", Age = 12, ClassName = "SSC"
                }
            };

            Assert.IsFalse(coll1 == coll2);
            Assert.IsTrue(CollectionUtils.IsEqualCollection(coll1, coll2, (x) => coll2.Contains(x)));
            Assert.IsTrue(CollectionUtils.IsEqualCollection(std1, std2, (x) => std2.Any(i => i.Age == x.Age && i.Name == x.Name && i.ClassName.Equals(x.ClassName))));
        }
        public void TestCloneSuccess()
        {
            var studentList = CollectionsMockBuilder.GetValidStudentsList();
            var actual      = CollectionUtils.Clone(studentList);
            var newStudent  = new Student("newName", 1, "10th");

            actual.Add(newStudent);
            Assert.IsTrue(!studentList.Contains(newStudent));
            Assert.IsTrue(actual.Contains(newStudent));
        }
        public void TestCollateWithComaparerSuccess()
        {
            var students1 = CollectionsMockBuilder.GetValidStudentsList();
            var students2 = new List <Student>
            {
                new Student()
                {
                    Name = "AA", Age = 17, ClassName = "SSC"
                },
                new Student()
                {
                    Name = "BB", Age = 23, ClassName = "SSC"
                },
                new Student()
                {
                    Name = "CC", Age = 14, ClassName = "SSC"
                }
            };
            var actual = CollectionUtils.Collate(students1, students2, new StudentComparer(), false);

            Assert.IsNotNull(actual);
            Assert.AreEqual(6, actual.Count);
        }