Example #1
0
        static void AnalyzeDigit(IDigitReader digitReader)
        {
            var trafficLightService = new TrafficLightService(digitReader);
            var filters = new List<INumberFilter> { new SequenceDigitFilter(), new MaskDigitFilter() };
            var digitAnalyzer = new TrafficLightAnalyzer(trafficLightService, filters);
            var result = digitAnalyzer.Analyze();

            Console.WriteLine("Right answer is {0}", digitReader.GetRightAnswer());
            Console.WriteLine("Actual answer is {0} on step {1} after getting number {2}", result, digitReader.GetStep(), digitReader.GetLastNumber());
        }
Example #2
0
        public void TrafficLightAnalyzer_Analyze_CapacityAndCountAreEqual_ResultShouldBeTrue(int number, string[] noises)
        {
            var digitReader = GenerateDigits(number, noises);
            var trafficLightService = new TrafficLightService(digitReader);
            var filters = new List<INumberFilter> { new SequenceDigitFilter(), new MaskDigitFilter() };
            var digitAnalyzer = new TrafficLightAnalyzer(trafficLightService, filters);

            var actualResult = digitAnalyzer.Analyze();
            var expectedResult = digitReader.GetRightAnswer();
            Assert.AreEqual(expectedResult, actualResult);

            var expectedStepCount = digitReader.GetStep();
            var actualStepCount = digitReader.GetStep();
            Assert.AreEqual(expectedStepCount, actualStepCount);
        }