Ejemplo n.º 1
0
        public void QuickSort_ShouldBeSuccessfully(int[] input, int[] expected)
        {
            AlgorithmsLib al = new AlgorithmsLib();

            al.QuickSort(input, 0, input.Length - 1);
            Assert.True(input.SequenceEqual(expected));
        }
Ejemplo n.º 2
0
        public void BinarySearch_ShouldPass(int[] input, int valueToSearch, int expectedIndex)
        {
            AlgorithmsLib al     = new AlgorithmsLib();
            var           result = al.BinarySearch(input, valueToSearch);

            Assert.True(result == expectedIndex);
        }
Ejemplo n.º 3
0
        public void MergeSort_ShouldMergeSortSuccessful(int[] input, int[] expected)
        {
            AlgorithmsLib al = new AlgorithmsLib();

            int[] result = al.MergeSort(input);
            Assert.True(result.SequenceEqual(expected));
        }
Ejemplo n.º 4
0
        public void MergeTwoSortedList_ShouldMergeSuccessfull(int[] input1, int[] input2,
                                                              int[] expectedIntegerArray)
        {
            AlgorithmsLib al = new AlgorithmsLib();

            int[] result = al.MergeTwoSortedList(input1, input2);
            Assert.True(result.SequenceEqual(expectedIntegerArray));
        }
Ejemplo n.º 5
0
        public void Fabbonacci_getValueAtIndex_ShouldOutputCorrectly(
            int input, int expected
            )
        {
            AlgorithmsLib al     = new AlgorithmsLib();
            var           output = al.Fabbonacci_getValueAtIndex(input);

            Assert.Equal(expected, output);
        }
Ejemplo n.º 6
0
        public void Sum_ShouldProduceSumOfTheDigits(int input, int expected)
        {
            // arrange
            AlgorithmsLib al = new AlgorithmsLib();
            // act
            int result = al.sum(input);

            // assert
            Assert.True(result == expected);
        }
        public void FindNthRootMethodTest_DataSourceFileAlgorithmsTestXML()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");

            double number    = Convert.ToDouble(TestContext.DataRow["number"]);
            int    power     = Convert.ToInt32(TestContext.DataRow["power"]);
            double accurancy = Convert.ToDouble(TestContext.DataRow["accurancy"]);
            double expected  = Convert.ToDouble(TestContext.DataRow["expectedResult"]);

            Assert.AreEqual(expected, AlgorithmsLib.FindNthRoot(number, power, accurancy), accurancy);
        }
Ejemplo n.º 8
0
        public void SplitIntegerArray_ShouldProduceTwoSubArrays(int[] input, int[] expectedLeft, int[] expectedRight)
        {
            AlgorithmsLib al = new AlgorithmsLib();

            int[] resultLeft  = new int[] {};
            int[] resultRight = new int[] {};
            al.SplitIntegerArray(input, out resultLeft, out resultRight);

            Assert.True(resultLeft.SequenceEqual(expectedLeft));
            Assert.True(resultRight.SequenceEqual(expectedRight));
        }
Ejemplo n.º 9
0
        public void MakeAnagram_ShouldOutputCorrectNumber(
            int expectedDeletedCharacters,
            string a,
            string b
            )
        {
            AlgorithmsLib al     = new AlgorithmsLib();
            var           result = al.makeAnagram(a, b);

            Assert.True(expectedDeletedCharacters == result);
        }
Ejemplo n.º 10
0
        public void Graph_TopologicalSort_ShouldOutputCorrectly()
        {
            AdjacencyMatrixGraph amg = new AdjacencyMatrixGraph(5, GraphType.Directed);

            amg.addEdge(0, 1);
            amg.addEdge(0, 2);
            amg.addEdge(1, 3);
            amg.addEdge(3, 2);
            amg.addEdge(3, 4);
            amg.addEdge(2, 4);

            var expected = new int[] { 0, 1, 3, 2, 4 };

            AlgorithmsLib a       = new AlgorithmsLib();
            var           results = a.Graph_TopologicalSort(amg);

            Assert.True(results.SequenceEqual(expected));
        }
Ejemplo n.º 11
0
 public int FindNextBiggerMethod(int number)
 => AlgorithmsLib.FindNextBigger(number);
Ejemplo n.º 12
0
 public void FindNthRootMethodTest_WithData_0dot01_2__neg1ThrowArgumentException()
 => Assert.Throws <ArgumentException>(() => AlgorithmsLib.FindNthRoot(0.01, 2, -1));
Ejemplo n.º 13
0
 public void FindNthRootMethodTest_WithData_negative0dot01_2__0dot0001ThrowArgumentException()
 => Assert.Throws <ArgumentException>(() => AlgorithmsLib.FindNthRoot(-0.01, 2, 0.0001));
Ejemplo n.º 14
0
 public void FindNthRootMethod(double number, int power, double accuracy, double expectedResult)
 {
     Assert.AreEqual(AlgorithmsLib.FindNthRoot(number, power, accuracy), expectedResult, accuracy);
 }
 public void FindNthRootMethodTest_WithData_0dot001_neg2__0dot0001ThrowArgumentException()
 => AlgorithmsLib.FindNthRoot(0.001, -2, 0.0001);