public void TestCanValidateBowlingScoreRules()
        {
            // arrange
            TraditionalBowlingScoringCalculator traditionalBowlingScoringCalculator =
                new TraditionalBowlingScoringCalculator();
            TraditionalBowlingScoreCalculatorValidator traditionalBowlingScoreCalculatorValidator =
                new TraditionalBowlingScoreCalculatorValidator(traditionalBowlingScoringCalculator);

            // act
            BowlingScoreValidatorResultEnum bowlingScoreValidatorResult = traditionalBowlingScoreCalculatorValidator.ValidateBowlingScoreRules();

            // assert
            if (bowlingScoreValidatorResult == BowlingScoreValidatorResultEnum.ScoreCalculatorValidationServiceInaccesible)
            {
                Assert.Inconclusive("The REST service that's used to validate the bowlingscore-rules is currently unavailable");
            }
            else
            {
                Assert.AreEqual(bowlingScoreValidatorResult, BowlingScoreValidatorResultEnum.ScoreCalculatorWorksFine);
            }
        }
示例#2
0
        public BowlingScoreValidatorResultEnum ValidateBowlingScoreRules()
        {
            try
            {
                TestGameDataDto      playedFramesTestData = GetPlayedTestFramesFromRestApi(out _apiValidationToken);
                IList <BowlingFrame> playedBowlingFrames  = ConvertTestDataToBowlingFrames(playedFramesTestData);

                CalculatedBowlingScoresDto      calculatedBowlingGameScoreDto = ConstructScoresToValidate(playedBowlingFrames, _scoreCalculator);
                BowlingScoreValidatorResultEnum validationResult = ValidateCalculatedGameScoreAgainstApi(calculatedBowlingGameScoreDto);

                return(validationResult);
            }
            catch (WebException)
            {
                return(BowlingScoreValidatorResultEnum.ScoreCalculatorValidationServiceInaccesible);
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#3
0
        private static void Main(string[] args)
        {
            Console.WriteLine(@"GREETINGS PROFESSOR FALKEN.");
            Console.WriteLine(@"SHALL WE PLAY A GAME?");
            Console.WriteLine(@"SIMULATING INDIVIDUAL GAMES OF BOWLING.");

            TraditionalBowlingScoringCalculator        traditionalBowlingScoreCalculator = new TraditionalBowlingScoringCalculator();
            TraditionalBowlingScoreCalculatorValidator bowlingScoreValidator             = new TraditionalBowlingScoreCalculatorValidator(traditionalBowlingScoreCalculator);

            for (int i = 1; i <= 10; i++)
            {
                try
                {
                    BowlingScoreValidatorResultEnum calculatedScoresValidateCorrectly = bowlingScoreValidator.ValidateBowlingScoreRules();
                    switch (calculatedScoresValidateCorrectly)
                    {
                    case BowlingScoreValidatorResultEnum.ScoreCalculatorWorksFine:
                        Console.WriteLine($"Game {i} was scored and validated correctly.");
                        break;

                    case BowlingScoreValidatorResultEnum.ScoreCalculatorWorksNotSoMuch:
                        Console.WriteLine($"Could not validate scores for Game {i}.");
                        break;

                    case BowlingScoreValidatorResultEnum.ScoreCalculatorValidationServiceInaccesible:
                        Console.WriteLine($"Could not validate scores for Game {i} - validation-service could not be reached.");
                        break;
                    }

                    System.Threading.Thread.Sleep(5000);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Could not validate scores for Game {i} - some error '{ex.Message}' got in the way.");
                }
            }

            Console.WriteLine("PRESS ANY KEY TO EXIT.");
            Console.ReadKey();
        }