Beispiel #1
0
        public void Should_execute_all_methods_in_correct_order()
        {
            var entity = new EntityClass{ PropertyA = 1, PropertyC= 5};
            var calculator = new EntityClassCalculator();

            var executor = new CalculationExecutor<EntityClass, EntityClassCalculator>(calculator);
            executor.Execute(entity);

            Assert.That(entity.PropertyA, Is.EqualTo(1));
            Assert.That(entity.PropertyB, Is.EqualTo(3));
            Assert.That(entity.PropertyC, Is.EqualTo(5));
            Assert.That(entity.PropertyD, Is.EqualTo(13));
            Assert.That(entity.PropertyE, Is.EqualTo(26));
            Assert.That(entity.PropertyF, Is.EqualTo(139));
            Assert.That(entity.PropertyG, Is.EqualTo(50));
        }
Beispiel #2
0
        static int Main(string[] args)
        {
            Console.WriteLine($"Starting fibonacci series calculation");

            // handle the args
            var argsParser = new ArgsParser();
            var argsResult = argsParser.ParseArgs(args);

            if (!argsResult.IsParsedSuccessfully || argsResult.MaxIndex <= 0)
            {
                if (!string.IsNullOrEmpty(argsResult.ParseFailedMessage))
                {
                    Console.WriteLine(argsResult.ParseFailedMessage);
                }

                Console.WriteLine(argsParser.GetHelpText());
                return(1);
            }

            var recursiveCalculator    = new RecursiveFibobanacciCalculator();
            var nonRecursiveCalculator = new NonRecursiveFibobanacciCalculator();
            var executor = new CalculationExecutor(recursiveCalculator, nonRecursiveCalculator);

            //warm up the execution
            executor.Execute(1);
            executor.Execute(10);

            //execution - generate a comma separate data for further analysis
            WriteDataTableHeader("Index", "Recursive Result", "Recursive Time(ms)", "Recursive Time(ms) - Log", "Non-Recursive Result", "Non-Recursive Time (ms)");
            for (int i = 1; i < argsResult.MaxIndex; i++)
            {
                var result = executor.Execute(i);
                WriteDataTableRow(i, result.RecursiveFibonacciValue, result.RecursiveTimeInMilliseconds, result.NonRecursiveFibonacciValue, result.NonRecursiveTimeInMilliseconds);
            }

            Console.WriteLine("Press any key to terminate");
            Console.ReadLine();

            return(0);
        }