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 TestCollectFromParentWithNullInputThrowsException() { var parentList = CollectionsMockBuilder.GetValidParentList(); parentList.Add(new Parent()); Assert.Throws <NullReferenceException>(() => CollectionUtils.CollectFromParent <Parent, Child>(null)); }
public void TestCollectFromChildSuccess() { var childList = CollectionsMockBuilder.GetValidChildList(); var actual = CollectionUtils.CollectFromChild <Child, Parent>(childList); Assert.IsTrue(actual.Any(i => i.ParentName.Equals("Parent1"))); }
public void TestCollectFromParentWithInvalidInputThrowsException() { var parentList = CollectionsMockBuilder.GetValidParentList(); parentList.Add(new Parent()); Assert.Throws <InvalidCastException>(() => CollectionUtils.CollectFromParent <Parent, Child>(parentList)); }
public void TestCollectFromParentSuccess() { var parentList = CollectionsMockBuilder.GetValidParentList(); var actual = CollectionUtils.CollectFromParent <Parent, Child>(parentList); Assert.IsTrue(actual.Any(i => i.ParentName.Equals("Parent1"))); }
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 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)); }
protected void OnSetup() { StringList = CollectionsMockBuilder.GetValidStringsList(); StrColl1 = new List <string> { "Satish", "Kumar" }; StrColl2 = new List <string> { "Satish", "KK" }; }
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); }