Beispiel #1
0
        public void FilterDigitsTest()
        {
            DataRow[] datas           = TestContext.DataRow.GetChildRows("parameteres_TestCase1");
            string    stringArrayTest = Convert.ToString(TestContext.DataRow["array"]);

            string[] bufStrings = stringArrayTest.Split(',');
            int[]    testArray  = new int[bufStrings.Length];
            for (int i = 0; i < bufStrings.Length; i++)
            {
                testArray[i] = Convert.ToInt32(bufStrings[i]);
            }

            int testNumber = Convert.ToInt32(TestContext.DataRow["number"]);

            int[] actualArray   = ArrayModifier.FilterDigits(testArray, testNumber);
            int[] expectedArray = { 12, 12, 100 };
            CollectionAssert.AreEqual(actualArray, expectedArray);
        }
 public void FilterDigitsTest_WithNullPredicate()
 {
     Assert.Throws <ArgumentNullException>(() => ArrayModifier.FilterDigits(testArray, null));
 }
 public void FilterDigitsTest_WithNullArray()
 {
     Assert.Throws <ArgumentNullException>(() => ArrayModifier.FilterDigits(null, new PredicateNumberContainsDigit()));
 }
        public void FilterDigitsTest_NumberIsDividedByValue()
        {
            int[] expectedArray = { 13, -26, 0, -117 };

            CollectionAssert.AreEqual(expectedArray, ArrayModifier.FilterDigits(testArray, new PredicateNumberIsDividedByValue()));
        }
        public void FilterDigitsTest_NumberContainsDigit()
        {
            int[] expectedArray = { -1199, -90 };

            CollectionAssert.AreEqual(expectedArray, ArrayModifier.FilterDigits(testArray, new PredicateNumberContainsDigit()));
        }
        public void FilterDigitsTest_NumberIsPositive()
        {
            int[] expectedArray = { 13, 11, 14 };

            CollectionAssert.AreEqual(expectedArray, ArrayModifier.FilterDigits(testArray, new PredicateNumberIsPositive()));
        }
 public int[] FilterDigits_TestArray(int[] array, int number)
 {
     return(ArrayModifier.FilterDigits(array, number));
 }
 public void FilterDigits_NumberIsMoreThan9_ArgumentException()
 => Assert.Throws <ArgumentException>(() => ArrayModifier.FilterDigits(Array.Empty <int>(), 24));
 public void FilterDigits_Null_ArgumentNullException()
 => Assert.Throws <ArgumentNullException>(() => ArrayModifier.FilterDigits(null, 0));