Exemple #1
0
        public void SubtractionOperator_DuplicateValues_RemoveAllValues()
        {
            // Arrange
            XanderList <int> expected  = new XanderList <int>();
            XanderList <int> actual    = new XanderList <int>();
            XanderList <int> testList1 = new XanderList <int>();
            XanderList <int> testList2 = new XanderList <int>();

            // adding to expected list
            expected.Add(1);

            // adding to testList1
            testList1.Add(1);
            testList1.Add(2);
            testList1.Add(2);
            testList1.Add(3);

            // adding to testList2
            testList2.Add(2);
            testList2.Add(3);

            // Act
            actual = testList1 - testList2;

            // Assert
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Exemple #2
0
        public void IEnumerator_LoopThroughList_CreatesStringOfAllNumbersInList()
        {
            // Arrange
            XanderList <int> expected = new XanderList <int>();
            XanderList <int> actual   = new XanderList <int>();

            XanderList <int> testList = new XanderList <int>();

            testList.Add(1);
            testList.Add(2);
            testList.Add(3);

            // add to expected list
            expected.Add(1);
            expected.Add(2);
            expected.Add(3);

            // Act
            foreach (int number in testList)
            {
                actual.Add(number);
            }

            // Assert
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Exemple #3
0
        public void Zip_OneListIsEmpty_ReturnSameList()
        {
            // Arrange
            XanderList <int> expected  = new XanderList <int>();
            XanderList <int> actual    = new XanderList <int>();
            XanderList <int> testList1 = new XanderList <int>();
            XanderList <int> testList2 = new XanderList <int>();

            // add to testList1
            testList1.Add(1);
            testList1.Add(2);
            testList1.Add(3);


            // add to expected list
            expected.Add(1);
            expected.Add(2);
            expected.Add(3);

            // Act
            actual = testList1.Zip(testList2);

            // Assert
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Exemple #4
0
        public void Zip_BothListsAreSameSize_ElementsAreInCorrectPosition()
        {
            // Assign
            XanderList <int> expected     = new XanderList <int>();
            XanderList <int> actual       = new XanderList <int>();
            XanderList <int> oddTestList  = new XanderList <int>();
            XanderList <int> evenTestList = new XanderList <int>();

            // add to oddTestList
            oddTestList.Add(1);
            oddTestList.Add(3);
            oddTestList.Add(5);

            // add to evenTestList
            evenTestList.Add(2);
            evenTestList.Add(4);
            evenTestList.Add(6);

            // add to expected list
            expected.Add(1);
            expected.Add(2);
            expected.Add(3);
            expected.Add(4);
            expected.Add(5);
            expected.Add(6);

            // Act
            actual = oddTestList.Zip(evenTestList);

            // Assert
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Exemple #5
0
        public void SubtractionOperator_DifferentSizedLists_ReturnListWithCorrectValues()
        {
            // Assign
            XanderList <int> expected  = new XanderList <int>();
            XanderList <int> actual    = new XanderList <int>();
            XanderList <int> testList1 = new XanderList <int>();
            XanderList <int> testList2 = new XanderList <int>();

            // add to list1
            testList1.Add(21);
            testList1.Add(22);
            testList1.Add(23);
            testList1.Add(24);

            // add to list2
            testList2.Add(100);
            testList2.Add(57);
            testList2.Add(1009);
            testList2.Add(21);
            testList2.Add(20);

            // add to expected XanderList
            expected.Add(22);
            expected.Add(23);
            expected.Add(24);

            // Act
            actual = testList1 - testList2;

            // Assert
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Exemple #6
0
        public void SubtractionOperator_BothListsHaveSameValues_ReturnEmptyList()
        {
            // Assign
            XanderList <int> expected  = new XanderList <int>();
            XanderList <int> actual    = new XanderList <int>();
            XanderList <int> testList1 = new XanderList <int>();
            XanderList <int> testList2 = new XanderList <int>();

            // add to list1
            testList1.Add(1);
            testList1.Add(2);
            testList1.Add(3);
            testList1.Add(4);

            // add to list2
            testList2.Add(1);
            testList2.Add(2);
            testList2.Add(3);
            testList2.Add(4);

            // Act
            actual = testList1 - testList2;

            // Assert
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Exemple #7
0
        public void AdditionOperator_DifferentSizedLists_ReturnListContainingAllValues()
        {
            // Arrange
            XanderList <int> actual    = new XanderList <int>();
            XanderList <int> expected  = new XanderList <int>();
            XanderList <int> testList1 = new XanderList <int>();
            XanderList <int> testList2 = new XanderList <int>();

            // add to testList1
            testList1.Add(1);
            testList1.Add(2);
            testList1.Add(3);

            // add to testList2
            testList2.Add(4);
            testList2.Add(5);

            // add to expected XanderList
            expected.Add(1);
            expected.Add(2);
            expected.Add(3);
            expected.Add(4);
            expected.Add(5);

            // Act
            actual = testList1 + testList2;

            // Assert
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Exemple #8
0
        public void Zip_IntBothListsAreEmpty_ReturnAnEmptyList()
        {
            // Arrange
            XanderList <int> expected = new XanderList <int>();
            XanderList <int> actual   = new XanderList <int>();

            XanderList <int> testList1 = new XanderList <int>();
            XanderList <int> testList2 = new XanderList <int>();

            // Act
            testList1 = testList1.Zip(testList2);

            // Assert
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Exemple #9
0
        public void ToString_Int_ReturnAllIntsWithSpaceBetween()
        {
            // Assign
            XanderList <int> testList = new XanderList <int>();

            testList.Add(1);
            testList.Add(2);
            testList.Add(3);
            testList.Add(4);

            string expected = "1 2 3 4";
            string actual;

            // Act
            actual = testList.ToString();

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #10
0
        public void ToString_Object_ReturnObjectToString()
        {
            // Assign
            string expected;
            string actual;

            XanderList <ObjTestClass> testList = new XanderList <ObjTestClass>();

            testList.Add(new ObjTestClass("John"));
            testList.Add(new ObjTestClass("Wick"));
            testList.Add(new ObjTestClass());
            testList.Add(new ObjTestClass());

            // Act
            expected = "CustomList.ObjTestClass CustomList.ObjTestClass CustomList.ObjTestClass CustomList.ObjTestClass";
            actual   = testList.ToString();

            //Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #11
0
        public void ToString_Double_ReturnAllDoublesWithSpaceBetween()
        {
            // Assign
            string expected;
            string actual;

            XanderList <double> testList = new XanderList <double>();

            testList.Add(3.1);
            testList.Add(3.2);
            testList.Add(3.3);
            testList.Add(90.9876770000);
            testList.Add(56.7891770000);

            // Act
            expected = "3.1 3.2 3.3 90.987677 56.789177";
            actual   = testList.ToString();

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #12
0
        public void ToString_Boolean_ReturnBooleanValuesWithSpacesBetween()
        {
            // Assign
            string expected;
            string actual;

            XanderList <bool> testList = new XanderList <bool>();

            testList.Add(true);
            testList.Add(true);
            testList.Add(true);
            testList.Add(false);
            testList.Add(false);
            testList.Add(false);

            // Act
            expected = "True True True False False False";
            actual   = testList.ToString();

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #13
0
        public void AdditionOperator_JoinTwoLists_ReturnOneList()
        {
            // Arrange
            XanderList <int> expected  = new XanderList <int>();
            XanderList <int> actual    = new XanderList <int>();
            XanderList <int> testList1 = new XanderList <int>();
            XanderList <int> testList2 = new XanderList <int>();

            testList1.Add(1);
            testList1.Add(2);
            testList2.Add(3);
            testList2.Add(4);
            expected.Add(1);
            expected.Add(2);
            expected.Add(3);
            expected.Add(4);

            // Act
            actual = testList1 + testList2;

            // Assert
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Exemple #14
0
        public void ToString_String_ReturnAllStringsWithSpaceBetween()
        {
            // Arrange
            string expected;
            string actual;

            XanderList <string> testList = new XanderList <string>();

            testList.Add("testing");
            testList.Add("the");
            testList.Add("tostring");
            testList.Add("method,");
            testList.Add("did");
            testList.Add("it");
            testList.Add("work?");

            // Act
            expected = "testing the tostring method, did it work?";
            actual   = testList.ToString();

            // Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #15
0
        public void Zip_ParameterListShorter_ElementsAreAtCorrectPosition()
        {
            // Assign
            XanderList <int> expected  = new XanderList <int>();
            XanderList <int> actual    = new XanderList <int>();
            XanderList <int> testList1 = new XanderList <int>();
            XanderList <int> testList2 = new XanderList <int>();

            // add to testList1
            testList1.Add(1);
            testList1.Add(2);
            testList1.Add(3);
            testList1.Add(4);
            testList1.Add(5);

            // add to testList2
            testList2.Add(1);
            testList2.Add(2);
            testList2.Add(3);

            // addd to expected list
            expected.Add(1);
            expected.Add(1);
            expected.Add(2);
            expected.Add(2);
            expected.Add(3);
            expected.Add(3);
            expected.Add(4);
            expected.Add(5);

            // Act
            actual = testList1.Zip(testList2);

            // Assert
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }