示例#1
0
        public void WhenNis95to99TheLastElementIs95(int n)
        {
            var result  = ListExercises.MakeFiveList(n);
            var lastPos = result.Count - 1;

            Assert.AreEqual(95, result[lastPos]);
        }
示例#2
0
        public void IfTheListIsEmptyTheAverageIsZero()
        {
            var argList = new List <double>();
            var result  = ListExercises.Average(argList);

            Assert.AreEqual(0, result);
        }
示例#3
0
        public static void Main(string[] args)
        {
            List myList = new List();

            for (int i = 0; i < 4; i++)
            {
                ListExercises list1 = new ListExercises();

                Console.WriteLine("Enter a name");
                list1.SetName(Console.ReadLine());

                if (myList.AddName(list1) == true)
                {
                    Console.WriteLine("Person Added");
                }
                else
                {
                    Console.WriteLine("No more space");
                    Console.ReadLine();
                }
                Console.WriteLine("Enter a name to find the position of: ");
                string personToFindPositionOf = Console.ReadLine();
                Console.WriteLine(personToFindPositionOf + "'s position is " + myList.GetPosition(personToFindPositionOf));
            }
        }
示例#4
0
        public void IfTheListIsEmptyAnEmptyListIsReturned()
        {
            var argList = new List <string>();
            var result  = ListExercises.MakeAList(argList);

            Assert.AreEqual(0, result.Count);
        }
示例#5
0
        public void GivenAListIsTheAverageCorrect()
        {
            var argList = new List <double> {
                5, 2, 6, 1
            };
            var result = ListExercises.Average(argList);

            Assert.AreEqual(3.5, result);
        }
示例#6
0
        public void IfTheListHasTwoWordsStartingWithAListOfSize2IsReturned()
        {
            var argList = new List <string> {
                "Cat", "Aarvaark", "ant", "Dog", "Budgie"
            };
            var result = ListExercises.MakeAList(argList);

            Assert.AreEqual(2, result.Count);
        }
示例#7
0
        public void IfTheListHasNoWordsStartingWithAAnEmptyListIsReturned()
        {
            var argList = new List <string> {
                "Cat", "Dog", "Budgie"
            };
            var result = ListExercises.MakeAList(argList);

            Assert.AreEqual(0, result.Count);
        }
示例#8
0
        public void IfTheListHasaWordsStartingWithATheWordIsReturned()
        {
            var argList = new List <string> {
                "Cat", "Aardvark", "Dog", "Budgie"
            };
            var result = ListExercises.MakeAList(argList);

            Assert.AreEqual(1, result.Count);
            Assert.Contains("Aardvark", result);
        }
示例#9
0
        public void IfTheListHasTwoWordsStartingWithATheCorrectWordsAreReturned()
        {
            var argList = new List <string> {
                "Cat", "Aardvark", "ant", "Dog", "Budgie"
            };
            var result = ListExercises.MakeAList(argList);

            Assert.Contains("Aardvark", result);
            Assert.Contains("ant", result);
        }
示例#10
0
        public static void Main(String[] args)
        {
            ListExercises myList = new ListExercises();

            Console.WriteLine("Enter five names, one per line");
            for (int i = 0; i < 5; i++)
            {
                myList.AddNameToList(Console.ReadLine());
            }
            Console.WriteLine("Results are " + myList.GetListAsString());
            Console.ReadLine();
        }
示例#11
0
 public bool AddName(ListExercises theListExercises)
 {
     if (nextFreeLocation < contents.Length)
     {
         contents[nextFreeLocation] = theListExercises;
         nextFreeLocation           = nextFreeLocation + 1;
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#12
0
        public void WhenNis0TheListisEmpty(int n)
        {
            var result = ListExercises.MakeFiveList(n);

            Assert.AreEqual(0, result.Count);
        }
示例#13
0
        public void WhenNis95to99TheListHas19Elements(int n)
        {
            var result = ListExercises.MakeFiveList(n);

            Assert.AreEqual(19, result.Count);
        }
示例#14
0
        public void WhenNis5to9TheListContains5(int n)
        {
            var result = ListExercises.MakeFiveList(n);

            Assert.AreEqual(5, result[0]);
        }
示例#15
0
        public void WhenNis5to9TheListHasOneElement(int n)
        {
            var result = ListExercises.MakeFiveList(n);

            Assert.AreEqual(1, result.Count);
        }