コード例 #1
0
ファイル: Program.cs プロジェクト: moyodancer/TestResults
       // static Dictionary<int, int> _CollatzLookup;

        static void Main(string[] args)
        {
            Console.WriteLine("Starting");
            IUserInputOutput userInputOutput = new FileUserInputOutput(_fileOutLocation);
            IChallengeCalculator challengeCalculator = new Computer();
            var inputs = userInputOutput.ReadInput();
            var outputs = new HashSet<Output>();

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            foreach (var input in inputs)
            {
                var maxCycle = challengeCalculator.CalculateMaxCycles(input);
                outputs.Add(new Output
                {
                    Input = input,
                    MaxCycle = maxCycle
                });
            }
            stopwatch.Stop();
            Console.WriteLine(stopwatch.Elapsed);
            Console.WriteLine("Completed");
            userInputOutput.PrintOutput(outputs);

            Console.WriteLine("Completed");
            Console.ReadLine();
        }
コード例 #2
0
        public void ReadFromFileInAppConfigTest()
        {
            var fileReader = new FileUserInputOutput(_fileOutLocation);

            var inputs = fileReader.ReadInput();
            IEnumerable<Input> expected = new HashSet<Input>
            {
                new Input
                {
                    Start = 1,
                    End = 10
                }
            };
            
            
            CollectionAssert.AreEqual(expected.ToList(), inputs.ToList());
        }
コード例 #3
0
        public void WriteToFileTest()
        {
            var fileWriter = new FileUserInputOutput(_fileOutLocation);

            var outputs = new HashSet<Output>
            {
                new Output
                {
                    Input = new Input
                    {
                        Start = 1,
                        End = 10
                    },
                    MaxCycle = 20
                }
            };

            fileWriter.PrintOutput(outputs);

            Assert.IsTrue(File.Exists(_fileOutLocation));
            //should add additional checks that read the file and compare to expected outputs

        }