[Test] public void TestConcatenation() { //Arrange ListmyList1 = new List { 1, 2, 3 }; List myList2 = new List { 4, 5, 6 }; //Act var concatenatedList = myList1.Concat(myList2).ToList(); //Assert Assert.AreEqual(new List { 1, 2, 3, 4, 5, 6 }, concatenatedList); }
[Test] public void TestConcatenationWithEmptyList() { //Arrange ListIn this example, we have one list that is empty. We use the Concat method to concatenate the empty list to the non-empty list. We then compare the concatenated list to the expected result. The package library used in both these examples would be System.Linq.myList1 = new List { 1, 2, 3 }; List myList2 = new List (); //Act var concatenatedList = myList1.Concat(myList2).ToList(); //Assert Assert.AreEqual(new List { 1, 2, 3 }, concatenatedList); }