コード例 #1
0
        public void OverloadAddOperator_CheckCombinedLists_NewListHasElementsFromSecondList()
        {
            CustomListClass <int> myList = new CustomListClass <int>();
            int value  = 8;
            int value2 = 16;
            int value3 = 32;
            int value4 = 64;
            int value5 = 128;

            myList.Add(value);
            myList.Add(value2);
            myList.Add(value3);
            myList.Add(value4);
            myList.Add(value5);
            CustomListClass <int> myList2 = new CustomListClass <int>();
            int num  = 8;
            int num2 = 16;
            int num3 = 32;
            int num4 = 64;
            int num5 = 128;

            myList2.Add(num);
            myList2.Add(num2);
            myList2.Add(num3);
            myList2.Add(num4);
            myList2.Add(num5);
            CustomListClass <int> combinedList = new CustomListClass <int>();

            combinedList = myList + myList2;
            Assert.AreEqual(num5, combinedList[9]);
        }
コード例 #2
0
        public void Remove_CheckIndex_NextIndexReplacesRemovedIndex()
        {
            //arrange
            CustomListClass <int> customList = new CustomListClass <int>();
            int value  = 1;
            int value2 = 2;
            int value3 = 3;
            int value4 = 4;
            int value5 = 5;
            int expected;
            int actual;

            // act
            customList.Add(value);
            customList.Add(value2);
            customList.Add(value3);
            customList.Add(value4);
            customList.Add(value5);
            expected = customList[2];
            customList.Remove(value2);
            actual = customList[1];

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        public void OverloadNegationOperator_CheckCombinedLists_NewListRemovesElementsFromFirstList()
        {
            CustomListClass <int> myList = new CustomListClass <int>();
            int value  = 8;
            int value2 = 16;
            int value3 = 32;
            int value4 = 64;
            int value5 = 128;

            myList.Add(value);
            myList.Add(value2);
            myList.Add(value3);
            myList.Add(value4);
            myList.Add(value5);
            CustomListClass <int> myList2 = new CustomListClass <int>();
            int num  = 7;
            int num2 = 15;
            int num3 = 32;
            int num4 = 65;
            int num5 = 127;

            myList2.Add(num);
            myList2.Add(num2);
            myList2.Add(num3);
            myList2.Add(num4);
            myList2.Add(num5);
            CustomListClass <int> removedList = new CustomListClass <int>();

            removedList = myList - myList2;
            Assert.AreEqual(value5, removedList[3]);
        }
コード例 #4
0
        public void Remove_CheckWholeList_ValueRemoved()
        {
            // arrange
            CustomListClass <int> customList = new CustomListClass <int>();
            int  value    = 1;
            int  value2   = 2;
            int  value3   = 3;
            int  value4   = 4;
            int  value5   = 5;
            bool expected = false;
            bool actual   = false;

            //act
            customList.Add(value);
            customList.Add(value2);
            customList.Add(value3);
            customList.Add(value4);
            customList.Add(value5);
            customList.Remove(value2);

            for (int i = 0; i > customList.Count; i++)
            {
                if (value2 == customList[i])
                {
                    actual = true;
                    break;
                }
            }
            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        public void AddTwoVariablesIndex_CheckIndex0And1_EachIntPlacedAtProperIndex()
        {
            CustomListClass <int> myList = new CustomListClass <int>();
            int value  = 8;
            int value2 = 16;

            myList.Add(value);
            myList.Add(value2);
            Assert.AreEqual(value2, myList[1]);
        }
コード例 #6
0
        public void AddThreeVariablesIndex_CheckIndex0And1And2_EachIntPlacedAtProperIndex()
        {
            CustomListClass <int> myList = new CustomListClass <int>();
            int value  = 8;
            int value2 = 16;
            int value3 = 32;

            myList.Add(value);
            myList.Add(value2);
            myList.Add(value3);
            Assert.AreEqual(value3, myList[2]);
        }
コード例 #7
0
        public Program()
        {
            CustomListClass <int> testList = new CustomListClass <int>();
            int expected = 4;
            int actual;

            // act
            testList.Add(1);
            testList.Add(2);
            testList.Add(3);
            testList.Add(4);
            testList.Add(5);
            actual = testList.Count;
        }
コード例 #8
0
        public void Add_AddToListWithExistingItem_CounterGoesUpOne()
        {
            // arrange
            CustomListClass <int> customList = new CustomListClass <int>();
            int expected = 2;
            int actual;

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

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #9
0
        public void Add_AddToListWithExistingItem_NewItemGoesToEndOfList()
        {
            // arrange
            CustomListClass <int> customList = new CustomListClass <int>();
            int expected = 2;
            int actual;

            // act
            customList.Add(1);
            customList.Add(2);
            actual = customList[1];

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #10
0
        public void Remove_RemoveFromEmptyList_ItemGoesToIndexZero()
        {
            // Arrange
            CustomListClass <int> testList = new CustomListClass <int>();
            int expected = 1;
            int actual;

            // act
            testList.Add(1);
            testList.Add(2);
            testList.Remove(2);
            actual = testList[0];

            Assert.AreEqual(expected, actual);
        }
コード例 #11
0
        public void Remove_OneItemFromList_CountGoesDownToOne()
        {
            // arrange
            CustomListClass <int> customList = new CustomListClass <int>();
            int expected = 1;
            int actual;

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

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #12
0
        public void Remove_ItemNotInList_ListStaysTheSame()
        {
            // arrange
            CustomListClass <int> customList = new CustomListClass <int>();
            int expected = 3;
            int actual;

            // act
            customList.Add(1);
            customList.Add(2);
            customList.Add(3);
            customList.Remove(4);
            actual = customList.Count;

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #13
0
        public void RemoveSpecificSingleVariableUnsuccessfully_CheckItemValue_ExistingVariablesUnChangedAfterFailedRemoval()
        {
            CustomListClass <int> myList = new CustomListClass <int>();
            int value  = 8;
            int value2 = 16;
            int value3 = 32;
            int value4 = 64;
            int value5 = 128;

            myList.Add(value);
            myList.Add(value2);
            myList.Add(value3);
            myList.Add(value4);
            myList.Add(value5);
            myList.Remove(100);
            Assert.AreEqual(value5, myList[4]);
        }
コード例 #14
0
        public void AddSingleVariableIndex_CheckIndex0_OneIntPlacedAtIndex0()
        {
            CustomListClass <int> myList = new CustomListClass <int>();
            int value = 8;

            myList.Add(value);
            Assert.AreEqual(value, myList[0]);
        }
コード例 #15
0
        public void Remove_ItemFromMiddleOfList_LastIndicieGoesToZero()
        {
            // arrange
            CustomListClass <int> customList = new CustomListClass <int>();
            int expected = 0;
            int actual;

            // act
            customList.Add(1);
            customList.Add(2);
            customList.Add(3);
            customList.Remove(1);
            actual = customList[2];

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #16
0
        public void Remove_FirstInstanceOfItemFromList_CountGoesDownToTwo()
        {
            // arrange
            CustomListClass <int> customList = new CustomListClass <int>();
            int expected = 2;
            int actual;

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

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #17
0
        public void RemoveSpecificSingleVariable_CheckIndexNumbers_IndexOfExistingVariablesUpdatedAfterRemove()
        {
            CustomListClass <int> myList = new CustomListClass <int>();
            int value  = 8;
            int value2 = 16;
            int value3 = 32;
            int value4 = 64;
            int value5 = 128;

            myList.Add(value);
            myList.Add(value2);
            myList.Add(value3);
            myList.Add(value4);
            myList.Add(value5);
            myList.Remove(value3);
            Assert.AreEqual(value4, myList[2]);
        }
コード例 #18
0
        public void ChangeValuesToString_CheckStringDesignation_LongListAlteredToString()
        {
            CustomListClass <int> myList = new CustomListClass <int>();
            int value  = 8;
            int value2 = 16;
            int value3 = 32;
            int value4 = 64;
            int value5 = 128;

            myList.Add(value);
            myList.Add(value2);
            myList.Add(value3);
            myList.Add(value4);
            myList.Add(value5);
            myList.ToString();
            Assert.AreEqual("8163264128", myList.ToString());
        }
コード例 #19
0
        // UnitOfWork--Method_StateUnderTest_ExpectedResult
        // write a test for when the array size changes (what is you array's starting size?)
        public void Add_AddToListAtMaxCapacity_ArraySizeDoubles()
        {
            // arrange
            CustomListClass <int> customList = new CustomListClass <int>();
            int expected = 5;
            int actual;

            // act
            customList.Add(1);
            customList.Add(2);
            customList.Add(3);
            customList.Add(4);
            customList.Add(5);
            actual = customList.Count;

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #20
0
        public void ToString_StringAddedToList_ConvertToOneString()
        {
            // arrange
            CustomListClass <string> customList = new CustomListClass <string>();
            string expected = "One,Two,Three,Four";
            string actual;

            // act
            customList.Add("One");
            customList.Add("Two");
            customList.Add("Three");
            customList.Add("Four");
            actual = customList.ToString();


            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #21
0
        public void ToString_IntAddedToList_ConvertToOneString()
        {
            // arrange
            CustomListClass <int> customList = new CustomListClass <int>();
            string expected = "1,2,3,4";
            string actual;

            // act
            customList.Add(1);
            customList.Add(2);
            customList.Add(3);
            customList.Add(4);
            actual = customList.ToString();


            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #22
0
        public void ToString_StringAddedToList_WriteLineHasListNotArray()
        {
            // arrange
            CustomListClass <string> customList = new CustomListClass <string>();
            string expected = "One,Two,Three,Four,Five";
            string actual;

            // act
            customList.Add("One");
            customList.Add("Two");
            customList.Add("Three");
            customList.Add("Four");
            customList.Add("Five");
            actual = customList.ToString();


            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #23
0
        public void Add_AddFiveToEmptyList_CountGoesToFive()
        {
            // arrange
            CustomListClass <int> testList = new CustomListClass <int>();
            int expected = 5;
            int actual;

            // act
            testList.Add(1);
            testList.Add(2);
            testList.Add(3);
            testList.Add(4);
            testList.Add(5);
            actual = testList.Count;

            // assert

            Assert.AreEqual(expected, actual);
        }
コード例 #24
0
        public void Remove_ItemFromList_ArraySizeStaysSame()
        {
            // arrange
            CustomListClass <int> customList = new CustomListClass <int>();
            int expected = 8;
            int actual;

            // act
            customList.Add(1);
            customList.Add(2);
            customList.Add(2);
            customList.Add(1);
            customList.Add(2);
            customList.Remove(2);
            actual = customList.Capacity;

            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #25
0
        public void Remove_ValueInList_ValueIsRemoved()
        {
            // Arrange
            CustomListClass <int> i = new CustomListClass <int>();

            i.Add(0);
            i.Add(1);
            i.Add(2);
            i.Add(3);
            i.Add(4);

            // Act
            i.Remove(2);

            // Assert
            int expected = 3;
            int actual   = i[2];

            Assert.AreEqual(expected, actual);
        }
コード例 #26
0
        public void Add_CheckIndex_ValueIsAtEnd() // should be descriptive of test
        {
            //arange
            CustomListClass <string> customList = new CustomListClass <string>();
            string input    = "words";
            string input2   = "other";
            string input3   = "something";
            string expected = input3;


            //act call method
            customList.Add(input);
            customList.Add(input2);
            customList.Add(input3);
            string actual = customList[2];


            //assert assert.
            Assert.AreEqual(expected, actual);
        }
コード例 #27
0
        public void AddToList()
        {
            //Arrange
            CustomListClass <int> list = new CustomListClass <int>();
            int expectedLength         = 1;

            //Act
            list.Add(6);
            //Assert
            Assert.AreEqual(expectedLength, list.Count);
        }
コード例 #28
0
        public void Remove_ValueNotInList_ListCountRemainsUnchanged()
        {
            // Arrange
            CustomListClass <int> i = new CustomListClass <int>();

            i.Add(0);
            i.Add(1);
            i.Add(2);
            i.Add(3);
            i.Add(4);
            int expected = 5;

            // Act
            i.Remove(5);

            // Assert
            int actual = i.Count;

            Assert.AreEqual(expected, actual);
        }
コード例 #29
0
        public void Add_CheckCapacity_CapacityIncreasesWhenLessThanCountMinus1() // should be descriptive of test
        {
            // arrange
            CustomListClass <int> customList = new CustomListClass <int>();
            int value    = 1;
            int value2   = 2;
            int value3   = 3;
            int value4   = 4;
            int value5   = 5;
            int value6   = 6;
            int expected = value6;

            // act call method
            customList.Add(value);
            customList.Add(value2);
            customList.Add(value3);
            customList.Add(value4);
            customList.Add(value5);
            customList.Add(value6);
            int count  = customList.Count;
            int actual = customList[5];


            // assert
            Assert.AreEqual(expected, actual);
        }
コード例 #30
0
        public void Add_AddToEmptyList_ItemGoesToIndexZero()
        {
            // Arrange
            CustomListClass <int> testList = new CustomListClass <int>();
            int expected = 1;
            int actual;

            // act
            testList.Add(expected);
            actual = testList[0];

            Assert.AreEqual(expected, actual);
        }