コード例 #1
0
        public void Add_CountIncreases_ByTwo()
        {
            //Arange
            CustomList <int> listOfNumbers2 = new CustomList <int>();
            int number1        = 5;
            int number2        = 10;
            int expectedResult = 4;
            int actualResult;

            //Act
            listOfNumbers2.AddMyItem(number1);
            listOfNumbers2.AddMyItem(number2);
            actualResult = listOfNumbers2.Capacity;
            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #2
0
        public void Add_String_Increases_One()
        {
            //Arange
            CustomList <string> listOfString1 = new CustomList <string>();
            string item1          = "soccer ball";
            string item2          = "tennis ball";
            string item3          = "golf ball";
            string expectedResult = "tennis ball";
            string actualResult;

            //Act
            listOfString1.AddMyItem(item1);
            listOfString1.AddMyItem(item2);
            listOfString1.AddMyItem(item3);
            actualResult = listOfString1[1];
            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #3
0
        public void Remove_OneItem_FromFive()
        {
            //Arrange
            CustomList <int> item = new CustomList <int>();
            int item1             = 11;
            int item2             = 15;
            int item3             = 20;

            int expectedResult = 15;
            int actualResult;

            //Act
            item.AddMyItem(item1);
            item.AddMyItem(item2);
            item.AddMyItem(item3);
            item.RemoveItem(item3);
            actualResult = item[1];
            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #4
0
        public void Remove_CountString_Decrease_ByTwo()
        {
            //Arrange
            CustomList <string> names = new CustomList <string>();
            string name1          = "tennis ball";
            string name2          = "golf ball";
            string name3          = "soccer ball";
            int    expectedResult = 1;
            int    actualResult;

            //Act
            names.AddMyItem(name1);
            names.AddMyItem(name2);
            names.AddMyItem(name3);
            names.RemoveItem(name1);
            names.RemoveItem(name2);
            actualResult = names.Count;
            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #5
0
        public void Remove_CapacityString_Decrease_ByThree()
        {
            //Arrange
            CustomList <string> reNames = new CustomList <string>();
            string name1          = "tennis ball";
            string name2          = "golf ball";
            string name3          = "soccer ball";
            int    expectedResult = 4;
            int    actualResult;

            //Act
            reNames.AddMyItem(name1);
            reNames.AddMyItem(name2);
            reNames.AddMyItem(name3);
            reNames.RemoveItem(name1);
            reNames.RemoveItem(name2);
            reNames.RemoveItem(name3);
            actualResult = reNames.Capacity;
            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #6
0
        public void Add_CountIncreases_ByOne()
        {
            //Arange
            CustomList <int> listOfNumbers1 = new CustomList <int>();  //empty list[      ]
            int number         = 9;
            int expectedResult = 1;
            int actualResult;

            //Act
            listOfNumbers1.AddMyItem(number);  //list with one value     [9 , , , ]
            actualResult = listOfNumbers1.Count;
            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #7
0
        public void Add_String_Increases()
        {
            //Arrange
            CustomList <string> listOfString2 = new CustomList <string>();
            string item1          = "soccer ball";
            string item2          = "baseball";
            string item3          = "tennis ball";
            string item4          = "tennis racket";
            string item5          = "golf ball";
            string expectedResult = "golf ball";
            string actualResult;

            //Act
            listOfString2.AddMyItem(item1);
            listOfString2.AddMyItem(item2);
            listOfString2.AddMyItem(item3);
            listOfString2.AddMyItem(item4);
            listOfString2.AddMyItem(item5);

            actualResult = listOfString2[4];

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
コード例 #8
0
        public void Remove_CountNumber_Decrease_ByOne()
        {
            //Arrange
            CustomList <int> items = new CustomList <int>();
            int number             = 10;
            int expectedResult     = 0;
            int actualResult;

            //Act
            items.AddMyItem(number);
            items.RemoveItem(number);
            actualResult = items.Count;
            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }