예제 #1
0
        public void Test1()
        {
            ArrayProcessor arrayProcessor = new ArrayProcessor();

            int[] testArray = { -10000, 10, 0, 1000, 1000, 5544, -5000, 3322, 7777, 2222, 9999, 120000 };

            // делаем копию массива что передаем, чтобы убедится что после работы программы исходный - не затрагивали
            int[] testArrayCopy = new int[testArray.Length];
            Array.Copy(testArray, testArrayCopy, testArray.Length);

            int[] result = arrayProcessor.SortAndFilter(testArray);

            Assert.Multiple(() =>
            {
                Assert.AreEqual(testArray, testArrayCopy);

                Assert.That(result, Is.Ordered);
                Assert.That(result, Has.All.InRange(1000, 9999));
            });

            testArray = new int[0];
            result    = arrayProcessor.SortAndFilter(testArray);
            Assert.AreEqual(testArray, result);

            testArray = new int[] { 1000, 1000, 1000 };
            result    = arrayProcessor.SortAndFilter(testArray);
            Assert.AreEqual(testArray, result);

            testArray = null;
            Assert.Throws <ArgumentNullException>(() => arrayProcessor.SortAndFilter(testArray));

            Assert.Pass();
        }
        public void TestSortAndFilter(int[] @in, int[] @out)
        {
            int[] result = _processor.SortAndFilter(@in);

            Assert.That(result, Is.Not.SameAs(@in));

            CollectionAssert.IsOrdered(result);

            CollectionAssert.AreEqual(result, @out);
        }
예제 #3
0
        public void Test_elements_Array()
        {
            ArrayProcessor array = new ArrayProcessor();

            int[] X = { -5, -2, -2, -2, -8, -5, 10, 11, 11, 45 };
            int[] B = { -5, -2, -8, 10, 11, 45 };
            int   a = array.SortAndFilter(X).Length;

            int[] Y = new int[a];
            Y = array.SortAndFilter(X);
            Array.Sort(B);
            CollectionAssert.AreEquivalent(B, Y);
        }
예제 #4
0
        public void NunitTestArraysortanddel()
        {
            var res_arr = _setarray.SortAndFilter(new int[] { -4, -4, 0, -3, -5, -3, 2, 1, 4, 7, 5, 6, 8, 9, 9 });

            int[] b;
            b = new int[] { -5, -4, -3, 0, 1, 2, 4, 5, 6, 7, 8, 9, 9 };
            CollectionAssert.AreEqual(res_arr, b);
        }
예제 #5
0
        public void IsOrdered()
        {
            ArrayProcessor processor = new ArrayProcessor();

            double[] array    = new double[] { 7, 5, 123, -50 };
            double[] newArray = processor.SortAndFilter(array);

            CollectionAssert.IsOrdered(newArray);
        }
예제 #6
0
        public void NoNegatives()
        {
            ArrayProcessor processor = new ArrayProcessor();

            double[] array    = new double[] { 7, 5, 123, -50 };
            double[] newArray = processor.SortAndFilter(array);

            Assert.Throws <InvalidOperationException>(() => newArray.First(item => item < 0));
        }
예제 #7
0
        public void SortTest()
        {
            double[]       a        = { 0, 3, 7, 1 };
            double[]       expected = { 7, 3, 1, 0 };
            ArrayProcessor arr      = new ArrayProcessor();

            double[] actual = arr.SortAndFilter(a);
            CollectionAssert.AreEqual(expected, actual);
        }
예제 #8
0
        public void AllConditionsTest()
        {
            double[]       a        = { 1, -1, 2, 3, 2, 73, 6, 2 };
            double[]       expected = { 73, 6, 3, 2, 1 };
            ArrayProcessor arr      = new ArrayProcessor();

            double[] actual = arr.SortAndFilter(a);
            CollectionAssert.AreEqual(expected, actual);
        }
예제 #9
0
        public void Delete_repeating_elements()
        {
            int[]          X     = { -5, -5, -5, -5, -5 };
            int[]          Y     = new int[X.Length];
            ArrayProcessor array = new ArrayProcessor();

            Y = array.SortAndFilter(X);
            Assert.AreEqual(-5, Y[0]);
        }
예제 #10
0
        public void ReplacingNegativeNumbersTest()
        {
            double[]       a        = { -76, -3, -1 };
            double[]       expected = { 76, 3, 1 };
            ArrayProcessor arr      = new ArrayProcessor();

            double[] actual = arr.SortAndFilter(a);
            CollectionAssert.AreEqual(expected, actual);
        }
예제 #11
0
        public void Sort_elements()
        {
            int[]          X     = { -5, -2, -8, 10, 11, 45 };
            int[]          Y     = new int[X.Length];
            ArrayProcessor array = new ArrayProcessor();

            Y = array.SortAndFilter(X);
            Array.Sort(X);
            CollectionAssert.AreEqual(X, Y);
        }
예제 #12
0
        public void NoDuplicates()
        {
            ArrayProcessor processor = new ArrayProcessor();


            double[] array    = new double[] { 7, 5, 123, -50 };
            double[] newArray = processor.SortAndFilter(array);

            CollectionAssert.AllItemsAreUnique(newArray);
        }
예제 #13
0
        public void SortAndFilter_originArr_originArrNotChange_()
        {
            int[] ororiginArr = new int[] { 0, -2, -5, -7, 9, -7, 12, -5, 4, 44, -2, 8 };
            int[] actualArr   = new int[] { 0, -2, -5, -7, 9, -7, 12, -5, 4, 44, -2, 8 };

            ArrayProcessor arrProc = new ArrayProcessor();

            int[] resultArr = arrProc.SortAndFilter(ororiginArr);

            CollectionAssert.AreEqual(ororiginArr, actualArr);
        }
예제 #14
0
        public void THeOriginalOneShouldRemainTheSame()
        {
            ArrayProcessor processor = new ArrayProcessor();

            double[] array = new double[] { 7, 5, 123, -50 };
            double[] copy  = new double[] { 7, 5, 123, -50 };

            double[] newArray = processor.SortAndFilter(array);

            CollectionAssert.AreEqual(array, copy);
        }
예제 #15
0
        public void SortAndFilter_originArr_ArrFilteredAndSorted_()
        {
            int[] ororiginArr = new int[] { 0, -2, -5, -7, 9, -7, 12, -5, 4, 44, -2, 8 };
            int[] expectedArr = new int[] { -7, -5, -2, 0, 4, 8, 9, 12, 44 };

            ArrayProcessor arrProc = new ArrayProcessor();

            int[] resultArr = arrProc.SortAndFilter(ororiginArr);

            CollectionAssert.AreEqual(resultArr, expectedArr);
        }
예제 #16
0
        public void CanSortAndFilterArrayMSUnit()
        {
            //Arrange
            ArrayProcessor ap2 = new ArrayProcessor();

            int[] tmp = { -10, 9, 9, 8, -3, -10, 4, 5, 1 };
            int[] fin = { -10, -3, 1, 4, 5, 8, 9, 9 };
            //Act
            tmp = ap2.SortAndFilter(tmp);
            //Assert
            //Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(fin, tmp);
        }
예제 #17
0
        public void CanSortAndFilterArrayAssertCollection()
        {
            //Arrange
            ArrayProcessor ap = new ArrayProcessor();

            int[] tmp = { -3, -10, 9, 9, 8, -3, -10, 4, 5, 1 };
            int[] fin = { -10, -3, 1, 4, 5, 8, 9, 9 };
            //Act
            tmp = ap.SortAndFilter(tmp);
            //Assert
            NUnit.Framework.CollectionAssert.AreEqual(fin, tmp);
        }
예제 #18
0
        public void testArrayProccessor()
        {
            //arange
            int[] actual    = { -8, 5443, -20, 4559, 0, -20, 2, -1323, 10000, -1323 };
            int[] excepting = { -1323, -20, -8, 0, 2, 4559, 5443, 10000 };

            //act
            ArrayProcessor arrProc = new ArrayProcessor();

            int[] result = arrProc.SortAndFilter(actual);

            //assert
            CollectionAssert.AreEqual(excepting, result);
        }
예제 #19
0
        public void testSameArray()
        {
            int[] actual    = { -8, 5443, -20, 4559, 0, -20, 2, -1323, 10000, -1323 };
            int[] excepting = { -8, 5443, -20, 4559, 0, -20, 2, -1323, 10000, -1323 };

            //act
            ArrayProcessor arrProc = new ArrayProcessor();

            int[] result = arrProc.SortAndFilter(actual);

            //assert
            //Проверяем, то оригинальный массив не меняется
            CollectionAssert.AreEqual(excepting, actual);
        }
예제 #20
0
 public void SortAndFilter_NegativeUnsorted_PositiveSorted()
 {
     double[] a = { 10, -5, 3, -8, 0 };
     double[] b = { 10, 5, 3, 8, 0 };
     CollectionAssert.AreEquivalent(array.SortAndFilter(a), b);
 }
예제 #21
0
 public void CollSortedTest()
 {
     CollectionAssert.IsOrdered(arrayProcessor.SortAndFilter(new int[] { 1, 2, 4444, 333, 5457, -10, -140, -4545, -777, 0, 55 }));
 }
예제 #22
0
        public void ThrowsWIthNull()
        {
            ArrayProcessor processor = new ArrayProcessor();

            Assert.Throws <ArgumentNullException>(() => processor.SortAndFilter(null));
        }
예제 #23
0
        public void TestPosition(int[] expectedResult, int[] obtainedResult)
        {
            ArrayProcessor arrayProcessor = new ArrayProcessor();

            CollectionAssert.AreEqual(expectedResult, arrayProcessor.SortAndFilter(obtainedResult));
        }