public void FindMissingReturnsMissingNumber()
        {
            var missing = MissingNumbers.FindMissing(AllNumbers, HasMissingNumber);

            Assert.AreNotEqual(missing, 0);
            Assert.AreEqual(missing, 7);
        }
コード例 #2
0
        public void MainFlow(string inputString)
        {
            var inputStream = new StringReader(inputString);
            var algor       = new MissingNumbers();

            int n = Convert.ToInt32(inputStream.ReadLine());

            int[] arr = Array.ConvertAll(inputStream.ReadLine().Split(' '), arrTemp => Convert.ToInt32(arrTemp))
            ;
            int m = Convert.ToInt32(inputStream.ReadLine());

            int[] brr = Array.ConvertAll(inputStream.ReadLine().Split(' '), brrTemp => Convert.ToInt32(brrTemp))
            ;
            int[] result = algor.missingNumbers(arr, brr);

            //textWriter.WriteLine(string.Join(" ", result));
        }
コード例 #3
0
        public void TestSearchMissingNumbers4()
        {
            //Arrange
            var        n   = 4;
            var        m   = 5;
            List <int> arr = new List <int> {
                301, 303, 304, 305
            };
            List <int> brr = new List <int> {
                301, 23302, 10303, 304, 305
            };
            string expectedResult = "Error_brr some List B items are greater than 10000";

            MissingNumbers search = new MissingNumbers();

            //Act
            var result = search.SearchMissingNumbers(n, m, arr, brr);

            //Assert
            Assert.AreEqual(expectedResult, result);
        }
コード例 #4
0
        public void TestSearchMissingNumbers3()
        {
            //Arrange
            var        n   = 4;
            var        m   = 5;
            List <int> arr = new List <int> {
                301, 303, 304, 305
            };
            List <int> brr = new List <int> {
                301, 302, 303, 304, 404
            };
            string expectedResult = "Error_Max_Min the maximum value of list B minus the minimum value is greater than 100";

            MissingNumbers search = new MissingNumbers();

            //Act
            var result = search.SearchMissingNumbers(n, m, arr, brr);

            //Assert
            Assert.AreSame(expectedResult, result);
        }
コード例 #5
0
        public void TestSearchMissingNumbers2()
        {
            //Arrange
            var        n   = 4;
            var        m   = 4;
            List <int> arr = new List <int> {
                301, 303, 304, 305
            };
            List <int> brr = new List <int> {
                301, 302, 303, 304
            };
            string expectedResult = "301";

            MissingNumbers search = new MissingNumbers();

            //Act
            var result = search.SearchMissingNumbers(n, m, arr, brr);

            //Assert
            Assert.AreNotSame(expectedResult, result);
        }
コード例 #6
0
        public void TestSearchMissingNumbers6()
        {
            //Arrange
            var        n   = 200000;
            var        m   = 300000;
            List <int> arr = new List <int> {
                301, 303, 304, 305, 306, 307
            };
            List <int> brr = new List <int> {
                301, 302, 303, 304, 305
            };
            string expectedResult = "Error_n Quantity List A is out of range";

            MissingNumbers search = new MissingNumbers();

            //Act
            var result = search.SearchMissingNumbers(n, m, arr, brr);

            //Assert
            Assert.AreEqual(expectedResult, result);
        }
コード例 #7
0
        public void TestSearchMissingNumbers1()
        {
            //Arrange
            var        n   = 10;
            var        m   = 13;
            List <int> arr = new List <int> {
                203, 204, 205, 206, 207, 208, 203, 204, 205, 206
            };
            List <int> brr = new List <int> {
                203, 204, 204, 205, 206, 207, 205, 208, 203, 206, 205, 206, 204
            };
            string expectedResult = "204 205 206";

            MissingNumbers search = new MissingNumbers();

            //Act
            var result = search.SearchMissingNumbers(n, m, arr, brr);

            //Assert
            Assert.AreEqual(expectedResult, result);
        }
コード例 #8
0
        public void TestSearchMissingNumbers5()
        {
            //Arrange
            var        n   = 6;
            var        m   = 5;
            List <int> arr = new List <int> {
                301, 303, 304, 305, 306, 307
            };
            List <int> brr = new List <int> {
                301, 302, 303, 304, 305
            };
            string expectedResult = "Error_n>m Quantity List A  is greater than Quantity List B";

            MissingNumbers search = new MissingNumbers();

            //Act
            var result = search.SearchMissingNumbers(n, m, arr, brr);

            //Assert
            Assert.AreEqual(expectedResult, result);
        }