Пример #1
0
        public void Test_filter_dataFilter()
        {
            // Arrange
            int[]      seq          = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            int        prime        = 7;
            dataFilter objLARGE     = new dataFilter(prime, seq);
            dataFilter objSMALL     = new dataFilter(prime, seq);
            dataFilter objNullLARGE = new dataFilter(prime);
            dataFilter objNullSMALL = new dataFilter(prime);

            int[] expectedLARGE     = new int[] { 8, 9, 10 };
            int[] expectedSMALL     = new int[] { 1, 2, 3, 4, 5, 6 };
            int[] expectedNullLARGE = new int[] { 7 };
            int[] expectedNullSMALL = new int[] { 7 };
            // Act
            objSMALL.switchMode();
            objNullSMALL.switchMode();
            int[] resultLARGE     = objLARGE.filter();
            int[] resultSMALL     = objSMALL.filter();
            int[] resultNullLARGE = objNullLARGE.filter();
            int[] resultNullSMALL = objNullSMALL.filter();
            // Assert
            CollectionAssert.AreEqual(resultLARGE, expectedLARGE);
            CollectionAssert.AreEqual(resultSMALL, expectedSMALL);
            CollectionAssert.AreEqual(resultNullLARGE, expectedNullLARGE);
            CollectionAssert.AreEqual(resultNullSMALL, expectedNullSMALL);
        }
Пример #2
0
        public void Test_dataFilter_DefaultConstructor()
        {
            // Arrange/Act
            dataFilter d = new dataFilter();

            int[] testArray = new int[1] {
                2
            };

            // Assert
            CollectionAssert.AreEqual(d.filter(), testArray);
        }
Пример #3
0
        public void Test_dataFilter_SetPrimeWithoutPrime()
        {
            // Arrange
            dataFilter d = new dataFilter(17);

            int[] testArray = new int[1] {
                17
            };

            // Act
            d.setPrime(18);

            // Assert
            CollectionAssert.AreEqual(d.filter(), testArray);
        }
Пример #4
0
        public void Test_dataFilter_FilterSmallMode()
        {
            // Arrange
            dataFilter d = new dataFilter(23);

            int[] testArray = new int[7] {
                25, 14, 29, 40, 8, 59, 2
            };
            int[] assertArray = new int[3] {
                14, 8, 2
            };

            // Act
            d.scramble(testArray); // Using scramble to set array, ignoring its output in this test
            int[] dFilter = d.filter();

            // Assert
            CollectionAssert.AreEqual(dFilter, assertArray);
        }
Пример #5
0
        public void Test_dataFilter_FilterLargeMode()
        {
            // Arrange
            dataFilter d = new dataFilter(41);

            d.setMode(true);
            int[] testArray = new int[7] {
                59, 24, 37, 15, 63, 104, 2
            };
            int[] assertArray = new int[3] {
                59, 63, 104
            };

            // Act
            d.scramble(testArray);
            int[] dFilter = d.filter();

            // Assert
            CollectionAssert.AreEqual(dFilter, assertArray);
        }