public void Add_TwoLists_CheckLastItmemIndex()
        {
            MyCustomList <int> list1 = new MyCustomList <int>();

            list1.Add(5);
            list1.Add(6);
            list1.Add(7);

            MyCustomList <int> list2 = new MyCustomList <int>();

            list2.Add(7);
            list2.Add(8);
            list2.Add(9);

            MyCustomList <int> listOnePlusTwo = new MyCustomList <int>();

            listOnePlusTwo.Add(5);
            listOnePlusTwo.Add(6);
            listOnePlusTwo.Add(7);
            listOnePlusTwo.Add(7);
            listOnePlusTwo.Add(8);
            listOnePlusTwo.Add(9);

            MyCustomList <int> actualCombinedList = new MyCustomList <int>();

            actualCombinedList = list1 + list2;
            int expected = 9;

            Assert.AreEqual(expected, actualCombinedList[5]);
        }
Exemple #2
0
        public void Add_Overload_Two_Ints_VerifyIndexZero()
        {
            //arrange
            MyCustomList <int> myList = new MyCustomList <int>();

            myList.Add(1);
            myList.Add(3);
            myList.Add(5);

            MyCustomList <int> myListTwo = new MyCustomList <int>();

            myListTwo.Add(2);
            myListTwo.Add(4);
            myListTwo.Add(6);

            MyCustomList <int> result = myList + myListTwo;
            int expected = 6;
            int actual;

            //act
            actual = result[3];

            //assert
            Assert.AreEqual(expected, actual);
        }
        public void Add_TwoLists_CheckExpactedCapasity()
        {
            MyCustomList <int> list1 = new MyCustomList <int>();

            list1.Add(5);
            list1.Add(6);
            list1.Add(7);

            MyCustomList <int> list2 = new MyCustomList <int>();

            list2.Add(7);
            list2.Add(8);
            list2.Add(9);

            MyCustomList <int> listOnePlusTwo = new MyCustomList <int>();

            listOnePlusTwo.Add(5);
            listOnePlusTwo.Add(6);
            listOnePlusTwo.Add(7);
            listOnePlusTwo.Add(7);
            listOnePlusTwo.Add(8);
            listOnePlusTwo.Add(9);
            MyCustomList <int> actualCombinedList = new MyCustomList <int>();


            int expected = 6;

            actualCombinedList = list1 + list2;

            Assert.AreEqual(expected, actualCombinedList.Count);
        }
Exemple #4
0
        public void Remove_PositiveValuesRemoveOddNumberedValue_VerifyEvenIndex()
        {
            //arrange
            MyCustomList <int> myList = new MyCustomList <int>();

            int expected = 0;
            int actual;

            //act
            myList.Add(60);
            myList.Add(69);
            myList.Add(42);
            myList.Add(347);
            myList.Add(751);

            myList.Remove(60);
            myList.Remove(69);
            myList.Remove(42);
            myList.Remove(347);
            myList.Remove(751);

            actual = myList.Count;

            //assert
            Assert.AreEqual(expected, actual);
        }
        public void Add_TwoLists_CheckIndexValueIndex0()
        {
            MyCustomList <int> list1 = new MyCustomList <int>();

            list1.Add(5);
            list1.Add(6);
            list1.Add(7);

            MyCustomList <int> list2 = new MyCustomList <int>();

            list2.Add(7);
            list2.Add(8);
            list2.Add(9);

            MyCustomList <int> listOnePlusTwo = new MyCustomList <int>();

            listOnePlusTwo.Add(5);
            listOnePlusTwo.Add(6);
            listOnePlusTwo.Add(7);
            listOnePlusTwo.Add(7);
            listOnePlusTwo.Add(8);
            listOnePlusTwo.Add(9);

            MyCustomList <int> actualCombinedList = new MyCustomList <int>();

            int expected = 5;

            actualCombinedList = list1 + list2;

            Assert.AreEqual(expected, actualCombinedList[0]);
        }
        public void ZippingTwoArraysTogetherOfDifferentLengths()
        {
            //Arrange
            MyCustomList <int> myList    = new MyCustomList <int>();
            MyCustomList <int> myListTwo = new MyCustomList <int>();
            int    valueOddOne           = 1;
            int    valueOddTwo           = 3;
            int    valueOddThree         = 5;
            int    valueOddFour          = 7;
            int    valueEvenOne          = 2;
            int    valueEvenTwo          = 4;
            int    valueEvenThree        = 6;
            string expected = "1234567";

            //Act
            myList.Add(valueOddOne);
            myList.Add(valueOddTwo);
            myList.Add(valueOddThree);
            myList.Add(valueOddFour);
            myListTwo.Add(valueEvenOne);
            myListTwo.Add(valueEvenTwo);
            myListTwo.Add(valueEvenThree);
            string actual = MyCustomList <T>().ToString();

            //Assert
            Assert.AreEqual(expected, actual);
        }
Exemple #7
0
        static void Main(string[] args)
        {
            /*---------------------------------------------- Zadanie 1 -----------------------------------------------*/
            Write(
                "/*---------------------------------- Zadanie 1 ----------------------------------*/"
                );
            const int             lenght       = 10;
            MyCustomList <string> myCustomList = new MyCustomList <string>(lenght);

            // Dodaj 5 elementów zaczynając od początku listy.
            for (var i = 0; i < 5; i++)
            {
                myCustomList.Add((i + 1).ToString());
            }

            // Wypisz dodane elementy.
            Write("\nWypisuje dodane elementy:");
            Write(myCustomList.Get(0));
            Write(myCustomList.Get(1));
            Write(myCustomList.Get(2));
            Write(myCustomList.Get(3));
            Write(myCustomList.Get(4));

            // Wypisz nowo dodany element
            Write("\nWypisuje nowo dodany element:");
            myCustomList.Add(6, 100.ToString());
            Write(myCustomList.Get(6));

            // Usuń element i wypisz wartość z tego indexu.
            Write("\nUsuwam element i sprawdzam wartość na wskazanym indexie:");
            myCustomList.Remove(0);
            Write(myCustomList.Get(0));

            // Pokaż i usuń ostatni niepusty element.
            Write("\nPobieram ostatni niepusty element i go usuwam (Pop()):");
            Write(myCustomList.Pop());

            // Długość.
            Write("\nDługość:");
            Write(myCustomList.Size());

            // Wyczyść listę
            Write("\nCzyszczę listę i pokazuję element z indexem 0:");
            myCustomList.Clear();
            Write(myCustomList.Get(0));

            /*---------------------------------------------- Zadanie 2 -----------------------------------------------*/
            Write(
                "/*---------------------------------- Zadanie 2 ----------------------------------*/"
                );
            Drawer square = new Square(10);

            square.Draw();
            Drawer rectangle = new Rectangle(10, 5);

            rectangle.Draw();
            Drawer triangle = new Triangle(9, 5);

            triangle.Draw();
        }
Exemple #8
0
        public void Add_OverloadTwoStringOrder()
        {
            //arrange
            MyCustomList <string> myList = new MyCustomList <string>();

            myList.Add("One");
            myList.Add("Two");
            myList.Add("Three");

            MyCustomList <string> myListTwo = new MyCustomList <string>();

            myListTwo.Add("Four");
            myListTwo.Add("Five");
            myListTwo.Add("Six");

            MyCustomList <string> results = myList + myListTwo;
            int expected = 6;


            int actual;

            //act

            actual = results.Count;

            //assert
            Assert.AreEqual(expected, actual);
        }
Exemple #9
0
    static void Main(string[] args)
    {
        int x = 1;
        int y = 2;
        var b = new MyCustomList <B>();

        b.Foo(v => v.P == x, n => n.P = y);
    }
Exemple #10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Student dhas = new Student("Manick", "Dhas", 22);
        Student raj  = new Student("Sundar", "Raj", 32);

        ///Using a custom strongly typed StudentList
        StudentList mc = new StudentList();

        mc.Add(dhas);
        mc.Add(raj);

        Response.Write("<B><U>Using a custom strongly typed StudentList</B></U><BR>");
        foreach (Student s in mc)
        {
            Response.Write("First Name : " + s.FirstName + "<BR>");
            Response.Write("Last Name : " + s.LastName + "<BR>");
            Response.Write("Age : " + s.Age + "<BR><BR>");
        }

        ///Creating a list of Student objects using my custom generics
        MyCustomList <Student> student = new MyCustomList <Student>();

        student.Add(dhas);
        student.Add(raj);

        Response.Write("<BR><B><U>Using a list of Student objects using my custom generics</B></U><BR>");
        foreach (Student s in student)
        {
            Response.Write("First Name : " + s.FirstName + "<BR>");
            Response.Write("Last Name : " + s.LastName + "<BR>");
            Response.Write("Age : " + s.Age + "<BR><BR>");
        }

        ///Creating a list of Student objects using my custom generics
        MyCustomList <int> intlist = new MyCustomList <int>();

        intlist.Add(1);
        intlist.Add(2);

        Response.Write("<BR><B><U>Using a list of String values using my custom generics</B></U><BR>");
        foreach (int i in intlist)
        {
            Response.Write("Index : " + i.ToString() + "<BR>");
        }

        ///Creating a list of Student objects using my custom generics
        MyCustomList <string> strlist = new MyCustomList <string>();

        strlist.Add("One");
        strlist.Add("Two");

        Response.Write("<BR><B><U>Using a list of int values using my custom generics</B></U><BR>");
        foreach (string str in strlist)
        {
            Response.Write("Index : " + str + "<BR>");
        }
    }
        public void Check_Value_IndexOfNextItemInListAfterAddingItemInTheList()
        {
            MyCustomList <int> list = new MyCustomList <int>();

            list.Add(5);

            int checkValue = list[1];

            Assert.AreEqual(checkValue, 0);
        }
        public void Check_Count_EmptyList()
        {
            MyCustomList <int> list = new MyCustomList <int>();

            int mycount = list.Count;



            Assert.AreEqual(mycount, 0);
        }
Exemple #13
0
        public void TestConstruct11()
        {
            int length = 1000000;
            MyCustomList <Car> list = new MyCustomList <Car>(length);

            //act

            //assert
            Assert.AreEqual(1048576, list.Capacity);
        }
Exemple #14
0
        public void TestConstruct03()
        {
            //arrange
            MyCustomList <Car> list = new MyCustomList <Car>();

            //act

            //assert
            Assert.AreEqual(0, list.Count);
        }
Exemple #15
0
        public void TestToString5()
        {
            //arrange
            MyCustomList <Car> list = new MyCustomList <Car>();

            //act

            //assert
            Assert.AreEqual("EMPTY LIST", list.ToString());
        }
        public void Check_Value_IndexZeroEmptyList()
        {
            MyCustomList <int> list = new MyCustomList <int>();

            int checkValue = list[0];



            Assert.AreEqual(checkValue, 0);
        }
Exemple #17
0
        public void TestConstruct08()
        {
            int length = 4;
            MyCustomList <Car> list = new MyCustomList <Car>(length);

            //act

            //assert
            Assert.AreEqual(4, list.Capacity);
        }
Exemple #18
0
        public void TestConstruct04()
        {
            int length = 40;
            MyCustomList <Car> list = new MyCustomList <Car>(length);

            //act

            //assert
            Assert.AreEqual(40, list.Count);
        }
Exemple #19
0
        public void TestCount1()
        {
            //arrange
            MyCustomList <int> list = new MyCustomList <int>();

            //act

            //assert
            Assert.AreEqual(0, list.Count);
        }
Exemple #20
0
        public void TestConstruct02()
        {
            //arrange
            int length = 40;
            MyCustomList <int> list = new MyCustomList <int>(length);

            //act

            //assert
            Assert.AreEqual(40, list.Count);
        }
Exemple #21
0
        public void TestAdd4()
        {
            //arrange
            MyCustomList <string> list = new MyCustomList <string>();

            //act
            list.Add("hello");

            //assert
            Assert.AreEqual(1, list.Count);
        }
Exemple #22
0
        public void TestAdd2()
        {
            //arrange
            MyCustomList <int> list = new MyCustomList <int>();

            //act
            list.Add(3);

            //assert
            Assert.IsNotNull(list.myArr[0]);
        }
        public void Add_String_CheckIndex2()
        {
            MyCustomList <string> list = new MyCustomList <string>();

            list.Add("Hello");
            list.Add("Mikola");
            list.Add("Zhmendak");
            string expected = "Zhmendak";

            Assert.AreEqual(expected, list[2]);
        }
        public void Add_String_CheckIfTheValueIsAssignedToCorrectIndex()
        {
            MyCustomList <string> list = new MyCustomList <string>();

            list.Add("Hello");
            list.Add("Mikola");
            list.Add("Zhmendak");
            string expected = "Zhmendak";

            Assert.AreEqual(expected, list[2]);
        }
Exemple #25
0
        public void TestAdd1()
        {
            //arrange
            MyCustomList <int> list = new MyCustomList <int>();

            //act
            list.Add(3);

            //assert
            Assert.AreEqual(3, list.myArr[0]);
        }
Exemple #26
0
        public void TestRemoveAll5()
        {
            //arrange
            MyCustomList <string> list = new MyCustomList <string>();

            //act
            list.RemoveAll("hello");

            //assert
            Assert.IsFalse(list.RemoveAll("hello"));
        }
Exemple #27
0
        public void TestAdd3()
        {
            //arrange
            MyCustomList <string> list = new MyCustomList <string>();

            //act
            list.Add("hello");

            //assert
            Assert.AreEqual("hello", list.myArr[0]);
        }
Exemple #28
0
        public void TestMethod1()
        {
            //Arrange
            MyCustomList <int> customList = new MyCustomList <int> ();
            int value         = 55;
            int expectedCount = 1;

            //Act
            customList.Add(value);
            //Assert
            Assert.AreEqual(expectedCount, customList.Count);
        }
Exemple #29
0
        public void Zip_IntsWithStrings()
        {
            MyCustomList<string> zipList1 = new MyCustomList<string>() { "Wisconsin Founded:", "Illinois Founded:" };
            MyCustomList<int> zipList2 = new MyCustomList<int>() { 1848, 1818};
            MyCustomList<string> expectedResult = new MyCustomList<string>() {"Wisconsin Founded:" 1848, "Illinois Founded:" 1818  };

            //Act
            MyCustomList<string> zipList3 = zipList1.ZipITwoLists(zipList2);

            //Assert
            Assert.AreEqual(expectedResult, zipList3);
        }
Exemple #30
0
        public void Zip_IntsToDecimals()
        {
            MyCustomList<int> zipList1 = new MyCustomList<int>() { 1, 2, 3, 4 };
            MyCustomList<double> zipList2 = new MyCustomList<double>() { .1, .2, .3, .4 };
            MyCustomList<double> expectedResult = new MyCustomList<double>() { 1.1, 2.2, 3.3, 4.4 };

            //Act
            MyCustomList<string> zipList3 = zipList1.ZipTwoLists(zipList2);

            //Assert
            Assert.AreEqual(expectedResult, zipList3);
        }
 public LargeDynamicViewModel()
 {
     Kittens = new MyCustomList();
 }
 public LargeFixedViewModel()
 {
     Kittens = new MyCustomList();
 }