コード例 #1
0
        public async Task CanCreateSeason()
        {
            var controller = new ManageSeasonController(_mediator);
            var inputModel = new CreateSeasonCommand()
            {
                Name = "2017"
            };

            var result = await controller.Create(inputModel);

            var verifySeason = await _verifyContext.Seasons.SingleOrDefaultAsync(s => s.Name == "2017");

            Assert.IsType <RedirectToActionResult>(result);
            Assert.Equal(verifySeason.Name, "2017");
        }
コード例 #2
0
        public async Task CanFailOnDuplicateSeasonNames()
        {
            var controller = new ManageSeasonController(_mediator);
            var inputModel = new CreateSeasonCommand {
                Name = "2017"
            };

            _testContext.Seasons.Add(new Season {
                Name = "2017"
            });
            _testContext.SaveChanges();
            var result = await controller.Create(inputModel) as ViewResult;

            Assert.NotNull(result);
            Assert.Equal(1, result.ViewData.ModelState.ErrorCount);
        }