コード例 #1
0
        public void Add_AddedItemToListCountIsFive_InputEqualsActual()
        {
            //arrange
            CustList <int> TestList   = new CustList <int>();
            int            inputValue = 5;

            //act
            TestList.Add(inputValue);
            int actualValue = TestList[0];

            //assert
            Assert.AreEqual(5, actualValue);
        }
コード例 #2
0
        public void Add_AddItemToListCountIsOne_InputEqualsActual()   //
        {
            //arrange
            CustList <int> TestList   = new CustList <int>();
            int            inputValue = 5;

            //act
            TestList.Add(inputValue);
            int actualCount = TestList.Count;

            //assert
            Assert.AreEqual(1, actualCount);
        }
コード例 #3
0
        public void Remove_CountDecreasesByOne_InputEqualsActual()
        {
            //arrange
            CustList <int> TestList = new CustList <int>();   // Testing to that the index count after is what one less than original, maybe this could also test that capacity remained the same

            TestList.Add(0);
            TestList.Add(1);
            TestList.Add(2);
            TestList.Add(3);
            //act
            TestList.Remove(1);
            int endCount       = 3;
            int actualEndCount = TestList.Count;      //index count should be 3, capacity still 4

            //assert
            Assert.AreEqual(endCount, actualEndCount);
        }
コード例 #4
0
        public void Add_CountIsNotExceeded_InputEqualsActual()
        {
            //arrange
            CustList <int> TestList      = new CustList <int>();
            int            originalCount = TestList.Count; // this is 4

            TestList.Add(0);
            TestList.Add(1);
            TestList.Add(2);
            TestList.Add(3);
            //act
            TestList.Add(4);                    // this shouldnt be able to happen
            int newCount = TestList.Count;

            //assert
            Assert.AreEqual(4, newCount);
        }
コード例 #5
0
        public void Remove_TakesCorrectIndexAway_InputEqualsActual()
        {
            //arrange
            CustList <string> TestList = new CustList <string>();  // Testing that the indexs are shifted to the left in the array (decreased an index)

            TestList.Add("a");
            TestList.Add("b");
            TestList.Add("c");
            TestList.Add("d");
            //act
            TestList.Remove("b");           // new array shoudl be [a, c, d, ,]

            string expectedString = TestList[1];

            //assert
            Assert.AreEqual(expectedString, "c");
            string expectedString2 = TestList[2];

            Assert.AreEqual(expectedString, "d");
            string expectedString3 = TestList[2];

            Assert.AreEqual(expectedString, " ");     // This test is the capacity remain 4 as well
        }