示例#1
0
        public void Count_CountsTheVariablesInArray_GivesCorrectNumberAfterAddingTwoAndRemovingOne()
        {
            //Arrange
            CustomList <int> shawnList = new CustomList <int>();
            int value  = 26;
            int value2 = 30;
            int expected;
            int actual;

            //Act
            shawnList.Add(value);
            shawnList.Add(value2);
            shawnList.Remove(shawnList[1]);
            actual   = shawnList.Count;
            expected = 1;

            //Assert
            Assert.AreEqual(expected, actual);
        }
示例#2
0
        public void Remove_RemoveRepeatedValue()
        {
            // arrange
            CustomList <int> testList = new CustomList <int>();
            int expected = 5;

            // act
            testList.Add(1);
            testList.Add(1);
            testList.Add(1);
            testList.Add(2);
            testList.Add(2);
            testList.Add(2);
            testList.Remove(1);
            int actual = testList.Count;

            // assert
            Assert.AreEqual(expected, actual);
        }
        public void Test_Of_Removing_One_Index_When_Multiple_Values_Are_The_Same()
        {
            //Arrange
            CustomList <int> myList = new CustomList <int>();
            int value         = 1;
            int value2        = 2;
            int expectedCount = 2;
            int actualCount;

            //Act
            myList.Add(value);
            myList.Add(value2);
            myList.Add(value);
            myList.Remove(value);
            actualCount = myList.Count;

            //Assert
            Assert.AreEqual(expectedCount, actualCount);
        }
示例#4
0
        public void Remove_CheckingIfDesiredVariableWasRemoved_CheckingIfAbleToRemoveString()
        {
            //arrange
            CustomList <string> shawnList = new CustomList <string>();
            string words;
            string actual;
            string expected;

            //act
            words = "Hello";
            shawnList.Add(words);
            shawnList.Remove("Hello");
            actual   = shawnList[0];
            expected = null;


            //assert
            Assert.AreEqual(expected, actual);
        }
        public void Remove_AddMultipleItemsToList_RemoveOnlyThatLastInstanceOfObject()
        {
            //arrange
            CustomList <int> testList = new CustomList <int>();
            int expected = 2;
            int actual;


            //act
            testList.Add(1);
            testList.Add(2);
            testList.Add(2);
            testList.Remove(2);
            actual = testList.Count;



            //assert
            Assert.AreEqual(expected, actual);
        }
示例#6
0
        public void CounterChecker3()
        {
            //Arrange

            CustomList <int> custom = new CustomList <int>();


            //Act

            custom.Add(1);
            custom.Add(2);
            custom.Add(3);
            custom.Add(4);
            custom.Add(20000);
            custom.Remove(1);


            //Assert
            Assert.AreEqual(custom[3], 20000);
        }
        public void DoesTheItemsShiftAfterRemovingItemFromTheMiddle()
        {
            //Arrange
            CustomList <int> ourCustomList = new CustomList <int>();

            ourCustomList.Add(6);
            ourCustomList.Add(8);
            ourCustomList.Add(12);
            ourCustomList.Add(32);
            ourCustomList.Add(7);
            int expectedValue = 32;
            int value;

            //Act
            ourCustomList.Remove(12);
            value = ourCustomList[2];

            //Assert
            Assert.AreEqual(expectedValue, value);
        }
示例#8
0
        public void Remove_OneNumber_MakeSureIndecencyCorrect()
        {
            //Arrange
            CustomList <int> myList = new CustomList <int>();
            int value10             = 17;
            int value11             = 29;
            int value12             = 72;
            int expected            = 72;



            //Act
            myList.Add(value10);
            myList.Add(value11);
            myList.Add(value12);
            myList.Remove(value11);

            //Assert
            Assert.AreEqual(expected, myList[1]);
        }
        public void Remove_ListContainsMultipleOfTheTarget_ListSans1stOccurrence()
        {
            //Arrange
            CustomList <int> customList = new CustomList <int>();

            customList.Add(1);
            customList.Add(2);
            customList.Add(1);

            CustomList <int> expectedResult = new CustomList <int>();

            expectedResult.Add(2);
            expectedResult.Add(1);
            //Act
            customList.Remove(1);
            CustomList <int> result = customList;

            //Assert
            Assert.IsTrue(ListsAreEqual(expectedResult, result));
        }
        public void Zip_OtherListIsEmpty_OriginalList()
        {
            //Arrange
            CustomList <int> customList1 = new CustomList <int>();
            CustomList <int> customList2 = new CustomList <int>();

            customList2.Add(1);
            customList2.Add(3);
            customList2.Add(5);
            customList1.Add(1);
            customList1.Remove(1);


            CustomList <int> expectedResult = customList2;
            //Act
            CustomList <int> result = CustomList <int> .Zip(customList1, customList2);

            //Assert
            Assert.IsTrue(ListsAreEqual(expectedResult, result));
        }
示例#11
0
        public void Remove_RemovingItemsFromArrayList_DoesValueOfIndex0StayAfterIndex1IsRemoved()
        {
            //Arrange
            CustomList <int> shawnList = new CustomList <int>();
            int value  = 26;
            int value2 = 30;
            int expected;
            int actual;


            //Act
            shawnList.Add(value);
            shawnList.Add(value2);
            shawnList.Remove(30);
            actual   = shawnList[0];
            expected = 26;

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void Remove_ListContains1OfTheTargetAtTheEnd_ListSansTarget()
        {
            //Arrange
            CustomList <int> customList = new CustomList <int>();

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

            CustomList <int> expectedResult = new CustomList <int>();

            expectedResult.Add(1);
            expectedResult.Add(2);
            //Act
            customList.Remove(3);
            CustomList <int> result = customList;

            //Assert
            Assert.IsTrue(ListsAreEqual(expectedResult, result));
        }
示例#13
0
        public void Remove_RemovingItemFromArray_RemovingOneItemWithMultipleCopiesOfSameValueCheckingFirstIndex()
        {
            //arrange
            CustomList <int> shawnList = new CustomList <int>();

            int expected;
            int actual;

            //act

            shawnList.Add(5);
            shawnList.Add(5);
            shawnList.Add(5);
            shawnList.Remove(5);
            expected = 5;
            actual   = shawnList[1];


            //assert
            Assert.AreEqual(expected, actual);
        }
        public void Remove_Item_Method_Does_Not_Change_Capacity()
        {
            //Arrange
            CustomList <int> collectionOfNumbers = new CustomList <int>();

            collectionOfNumbers.Add(4);
            collectionOfNumbers.Add(5);
            collectionOfNumbers.Add(6);
            collectionOfNumbers.Add(7);
            collectionOfNumbers.Add(9);

            collectionOfNumbers.Remove(9);
            int expected = 8;
            int actual;

            //Act
            actual = collectionOfNumbers.Capacity;

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void remove_Item_CountDecreases_ByOne()
        {
            //Arange

            CustomList <int> collectionOfNumbers = new CustomList <int>();

            int number1  = 9;
            int number2  = 7;
            int expected = 1;
            int actual;

            //Act
            collectionOfNumbers.Add(number1);
            collectionOfNumbers.Add(number2);
            collectionOfNumbers.Remove(number1);
            actual = collectionOfNumbers.Count;

            //Assert

            Assert.AreEqual(expected, actual);
        }
示例#16
0
        public void Value_Not_Contained_In_List_When_Removed()
        {
            //Arrange
            CustomList <int> list = new CustomList <int>();

            int valueToRemove = 54;

            list.Add(2);
            list.Add(6);
            list.Add(18);
            list.Add(54);
            list.Add(162);
            list.Add(486);
            bool expectedResult = false;

            //Act
            list.Remove(valueToRemove);
            bool actualResult = list.Contains(valueToRemove);

            Assert.AreEqual(expectedResult, actualResult);
        }
示例#17
0
        public void Remove_RemovesDesiredElement()
        {
            // arrange
            CustomList <int> testList = new CustomList <int>();
            int expected = 3;

            // act
            testList.Add(1);
            testList.Add(2);
            testList.Add(3);
            testList.Add(4);
            testList.Add(5);
            testList.Add(6);
            testList.Add(7);
            testList.Add(8);
            testList.Remove(2);
            int actual = testList[1];

            // assert
            Assert.AreEqual(expected, actual);
        }
        public void Remove_Item_AndChecksIfRemoved()
        {
            //Arrange
            CustomList <int> itemsToRemove = new CustomList <int>();
            int number1  = 4;
            int number2  = 5;
            int number3  = 6;
            int number4  = 7;
            int expected = 6;
            int actual;

            //Act
            itemsToRemove.Add(number1);
            itemsToRemove.Add(number2);
            itemsToRemove.Add(number3);
            itemsToRemove.Add(number4);
            itemsToRemove.Remove(number2);
            actual = itemsToRemove[1];
            //Assert
            Assert.AreEqual(expected, actual);
        }
示例#19
0
        public void Remove_RemoveItemNoExists_NothingRemoved()
        {
            //Arrange
            CustomList <int> testList = new CustomList <int>();

            testList.Add(111);
            testList.Add(222);
            int expected1 = 111;
            int expected2 = 222;
            int actual1;
            int actual2;

            //Act
            testList.Remove(1234);
            actual1 = testList[0];
            actual2 = testList[1];

            //Assert
            Assert.AreEqual(expected1, actual1);
            Assert.AreEqual(expected2, actual2);
        }
        public void SeeIfListIsAdjustedByOneIfAllValuesAreTheSame()
        {
            //Arrange
            CustomList <int> ourCustomList = new CustomList <int>();

            ourCustomList.Add(5);
            ourCustomList.Add(5);
            ourCustomList.Add(5);
            ourCustomList.Add(5);
            int isItemInList;
            int expectedValue = 3;

            //Act
            ourCustomList.Remove(5);

            isItemInList = ourCustomList.Count;


            //Assert
            Assert.AreEqual(expectedValue, isItemInList);
        }
示例#21
0
        public void ToString_ConvertingDesiredValueToString_CheckingIfLargeValueReturnedIsAStringAfterRemoving()
        {
            //arrange
            CustomList <int> shawnList = new CustomList <int>();
            string           actual;
            string           expected;

            //act
            shawnList.Add(5);
            shawnList.Add(5);
            shawnList.Add(5);
            shawnList.Add(5);
            shawnList.Add(5);
            shawnList.Add(5);
            shawnList.Remove(5);
            shawnList.ToString();
            actual   = shawnList.ToString();
            expected = "5, 5, 5, 5, 5";
            //assert
            Assert.AreEqual(expected, actual);
        }
示例#22
0
        public void RemoveMethod_ObjectIsRemovedFromListWithMultipleObjectsIdenticalToIt_OnlyOneObjectIsRemoved()
        {
            //arrange
            int expected = 3;
            int actual;
            int numberToBeAdded0  = 0;
            int numberToBeAdded1  = 1;
            int numberToBeAdded2  = 3;
            int numberToBeAdded3  = 3;
            CustomList <int> list = new CustomList <int>();

            //act
            list.Add(numberToBeAdded0);
            list.Add(numberToBeAdded1);
            list.Add(numberToBeAdded2);
            list.Add(numberToBeAdded3);
            list.Remove(3);
            actual = list.Count;
            //assert
            Assert.AreEqual(expected, actual);
        }
示例#23
0
        public void Remove_ItemFromTheList_ReturnItemAtIndex()
        {
            //arrange
            CustomList <string> customList = new CustomList <string>();
            string city1    = "Waukesha";
            string city2    = "Milwaukee";
            string city3    = "Brookfield";
            string expected = "Milwaukee";
            string actual;

            //act
            customList.Add(city1);
            customList.Add(city2);
            customList.Add(city1);
            customList.Add(city3);
            customList.Remove(city1);
            actual = customList[0];

            //assert
            Assert.AreEqual(expected, actual);
        }
        public void DoesIndexFourStayAtTheCorrectValueWhenFifthItemIsRemoved()
        {
            //Arrange
            CustomList <int> ourCustomList = new CustomList <int>();

            ourCustomList.Add(6);
            ourCustomList.Add(8);
            ourCustomList.Add(12);
            ourCustomList.Add(32);
            ourCustomList.Add(7);
            int indexExpectedValue = 32;
            int value;

            //Act
            ourCustomList.Remove(7);
            value = ourCustomList[4];



            //Assert
            Assert.AreEqual(indexExpectedValue, value);
        }
示例#25
0
        public void Remove_OneValue_GetCapacity()
        {
            //Arrange
            CustomList <int> myList = new CustomList <int>();
            int expected            = 8;
            int firstValue          = 7;
            int secondValue         = 11;
            int thirdValue          = 24;
            int fourthValue         = 32;
            int fifthValue          = 44;

            //Act
            myList.Add(firstValue);
            myList.Add(secondValue);
            myList.Add(thirdValue);
            myList.Add(fourthValue);
            myList.Add(fifthValue);
            myList.Remove(thirdValue);

            //Assert
            Assert.AreEqual(expected, myList.Capacity);
        }
示例#26
0
        public void Remove_Strings_CheckDifferentDataTypes()
        {
            //Arrange
            CustomList <string> myList = new CustomList <string>();
            string name     = "James";
            string name2    = "Leo";
            string name3    = "Frank";
            int    expected = 2;



            //Act
            myList.Add(name);
            myList.Add(name2);
            myList.Add(name3);
            myList.Remove(name2);



            //Assert
            Assert.AreEqual(expected, myList.Count);
        }
        public void Test_of_Remove_With_Checking_Last_Index()
        {
            //Arrange
            CustomList <int> myList = new CustomList <int>();
            int value         = 4;
            int value2        = 1;
            int value3        = 8;
            int value4        = 7;
            int expectedValue = 8;
            int actualValue;

            //Act
            myList.Add(value);
            myList.Add(value2);
            myList.Add(value3);
            myList.Add(value4);
            myList.Remove(value4);
            actualValue = myList[2];

            //Assert
            Assert.AreEqual(expectedValue, actualValue);
        }
示例#28
0
        public void Remove_ItemsThatDoesNotExistInList_ReturnCount()
        {
            //arrange
            CustomList <string> customList = new CustomList <string>();
            string city1    = "Waukesha";
            string city2    = "Pewaukee";
            string city3    = "New Berlin";
            string city4    = "Brookfield";
            int    expected = 4;
            int    actual;

            //act
            customList.Add(city1);
            customList.Add(city2);
            customList.Add(city3);
            customList.Add(city4);
            customList.Remove(city4);
            actual = customList.Capacity;

            //assert
            Assert.AreEqual(expected, actual);
        }
示例#29
0
        public void Remove_ItemsFromAList_ReturnNewCount()
        {
            //arrange
            CustomList <int> customList = new CustomList <int>();
            int num1     = 5;
            int num2     = 10;
            int num3     = 15;
            int num4     = 20;
            int expected = 3;
            int actual;

            //act
            customList.Add(num1);
            customList.Add(num2);
            customList.Add(num3);
            customList.Add(num4);
            customList.Remove(num3);
            actual = customList.Count;

            //assert
            Assert.AreEqual(expected, actual);
        }
        public void IsTheItemInTheListReturnFalse()
        {
            //Arrange
            CustomList <int> ourCustomList = new CustomList <int>();

            ourCustomList.Add(6);
            ourCustomList.Add(8);
            ourCustomList.Add(12);
            ourCustomList.Add(32);
            ourCustomList.Add(7);
            bool isItemInList;
            bool expectedValue = false;

            //Act
            ourCustomList.Remove(4);
            isItemInList = false;



            //Assert
            Assert.AreEqual(expectedValue, isItemInList);
        }