コード例 #1
0
        public void ProgressReturnPlayerProgressWhenBetIsValid()
        {
            // Arrange
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("config.json")
                                .Build();

            _config = Options.Create(configuration.Get <QuestConfiguration>());

            var controller = new ProgressController(_fakePlayerRepository, _config);

            var bet = new PlayerBet
            {
                PlayerId      = "P01",
                PlayerLevel   = 2,
                ChipAmountBet = 10
            };

            var player         = _fakePlayerRepository.GetPlayer(bet.PlayerId);
            var expectedResult = CalculateProgress(_config.Value, player, bet);

            //Act
            var result = controller.Progress(bet);

            //Assert
            var okObjectResult = Assert.IsType <OkObjectResult>(result);
            var model          = Assert.IsType <PlayerProgress>(okObjectResult.Value);

            Assert.Equal(expectedResult.TotalQuestPercentCompleted, model.TotalQuestPercentCompleted);
            Assert.True(expectedResult.MilestonesCompleted.All(shouldItem => model.MilestonesCompleted.Any(isItem => isItem.MilestoneIndex == shouldItem.MilestoneIndex && isItem.ChipsAwarded == shouldItem.ChipsAwarded)));
            Assert.Equal(expectedResult.QuestPointsEarned, model.QuestPointsEarned);
        }
コード例 #2
0
        public void ProgressReturnNotFoundWhenQuestConfigNotFound()
        {
            // Arrange
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("config.json")
                                .Build();

            _config             = Options.Create(configuration.Get <QuestConfiguration>());
            _config.Value.Quest = null;

            var controller = new ProgressController(_fakePlayerRepository, _config);

            var bet = new PlayerBet
            {
                PlayerId      = "P01",
                PlayerLevel   = 2,
                ChipAmountBet = 10
            };

            //Act
            var result = controller.Progress(bet);

            //Assert
            var notFoundObjectResult = Assert.IsType <NotFoundObjectResult>(result);

            Assert.Null(notFoundObjectResult.Value);
        }
コード例 #3
0
        public void ProgressReturnBadRequestWhenBetIsNull()
        {
            // Arrange
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("config.json")
                                .Build();

            _config = Options.Create(configuration.Get <QuestConfiguration>());

            var controller = new ProgressController(_fakePlayerRepository, _config);

            //Act
            var result = controller.Progress(null);

            //Assert
            Assert.IsType <BadRequestResult>(result);
        }