Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Stopwatch sw = new Stopwatch();

            int[] array = Enumerable.Range(1, 7_000_000).ToArray();
            sw.Start();
            DataManipulator.FilterDigit(array, 7);
            sw.Stop();
            Console.WriteLine(nameof(DataManipulator.FilterDigit) + " elapsed time: " + sw.ElapsedTicks);
            sw.Restart();
            DataManipulator.FilterDigit1(array, 7);
            sw.Stop();
            Console.WriteLine(nameof(DataManipulator.FilterDigit1) + " elapsed time: " + sw.ElapsedTicks);
            sw.Restart();
            DataManipulator.FilterDigit2(array, 7);
            sw.Stop();
            Console.WriteLine(nameof(DataManipulator.FilterDigit2) + " elapsed time: " + sw.ElapsedTicks);
            sw.Restart();
            DataManipulator.FilterDigit3(array, 7);
            sw.Stop();
            Console.WriteLine(nameof(DataManipulator.FilterDigit3) + " elapsed time: " + sw.ElapsedTicks);

            Console.ReadKey();
        }
 public void FilterDigit_NotDigitAsFilteringInput_ArgumentException()
 {
     DataManipulator.FilterDigit(new int[0], 12);
 }
 public void FilterDigit_EmptyCollection_ArgumentException()
 {
     DataManipulator.FilterDigit(new int[0], 7);
 }
 public void FilterDigit_NullCollection_ArgumentException()
 {
     DataManipulator.FilterDigit(null, 7);
 }
 public void FilterDigit_CollectionsContainingFilteredNumber_FilteredCollection()
 {
     int[] testData = new int[] { 7, 1, 2, 3, 4, 5, 6, 7, 68, 69, 70, 15, 17 };
     CollectionAssert.AreEquivalent(new int[] { 7, 7, 70, 17 }, DataManipulator.FilterDigit(testData, 7));
 }
 public void FilterDigit_NotDigitAsFilteringInput_ArgumentException()
 {
     int[] testData = new int[] { 7, 1, 2, 3, 4, 5, 6, 7, 68, 69, 70, 15, 17 };
     Assert.Throws <ArgumentException>(() => DataManipulator.FilterDigit(testData, 47));
 }
 public void FilterDigit_EmptyCollection_ArgumentException()
 {
     Assert.Throws <ArgumentException>(() => DataManipulator.FilterDigit(new int[0], 7));
 }
 public void FilterDigit_NullCollection_ArgumentException()
 {
     Assert.Throws <ArgumentException>(() => DataManipulator.FilterDigit(null, 7));
 }