Esempio n. 1
0
        public void 年度新規登録画面を表示()
        {
            // Arrange
            var mockUseCase = new Mock <ISeasonUseCase>();
            var controller  = new SeasonsController(mockUseCase.Object);

            // Act
            var result = controller.Register();

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.IsAssignableFrom <RegisterViewModel>(viewResult.ViewData.Model);
        }
Esempio n. 2
0
        public async void 年度を登録()
        {
            // Arrange
            var viewModel = new RegisterViewModel()
            {
                SeasonName            = "2020年度",
                FromDate              = new DateTime(2020, 4, 1),
                ToDate                = new DateTime(2021, 3, 31),
                RegistrationFromDate  = new DateTime(2020, 3, 31),
                TeamRegistrationFee   = 5000,
                PlayerRegistrationFee = 500,
                PlayerTradeFee        = 200
            };

            var season = new Season(
                "2020年度",
                new DateTime(2020, 4, 1),
                new DateTime(2021, 3, 31),
                new DateTime(2020, 3, 31),
                new TeamRegistrationFee(5000),
                new PlayerRegistrationFee(500),
                new PlayerTradeFee(200));

            var mockUseCase = new Mock <ISeasonUseCase>();

            mockUseCase.Setup(m => m.RegisterSeason("2020年度", new DateTime(2020, 4, 1), new DateTime(2021, 3, 31), new DateTime(2020, 3, 31), 5000, 500, 200))
            .ReturnsAsync(season)
            .Verifiable();
            var controller = new SeasonsController(mockUseCase.Object);

            // Act
            var result = await controller.Register(viewModel);

            // Assert
            mockUseCase.Verify();
            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Null(redirectToActionResult.ControllerName);
            Assert.Equal(nameof(controller.Edit), redirectToActionResult.ActionName);
        }
Esempio n. 3
0
        public async void 年度登録時無効な値の場合再表示()
        {
            // Arrange
            var viewModel = new RegisterViewModel()
            {
                SeasonName            = "2020年度",
                FromDate              = new DateTime(2020, 4, 1),
                ToDate                = new DateTime(2021, 3, 31),
                RegistrationFromDate  = new DateTime(2020, 3, 31),
                TeamRegistrationFee   = 5000,
                PlayerRegistrationFee = 500,
                PlayerTradeFee        = 200
            };

            var mockUseCase = new Mock <ISeasonUseCase>();
            var controller  = new SeasonsController(mockUseCase.Object);

            controller.ModelState.AddModelError("error", "some error");

            // Act
            var result = await controller.Register(viewModel);

            // Arrange
            var viewResult = Assert.IsType <ViewResult>(result);

            Assert.Null(viewResult.ViewName);
            var model = Assert.IsType <RegisterViewModel>(viewResult.ViewData.Model);

            Assert.Equal(viewModel.SeasonName, model.SeasonName);
            Assert.Equal(viewModel.FromDate, model.FromDate);
            Assert.Equal(viewModel.ToDate, model.ToDate);
            Assert.Equal(viewModel.RegistrationFromDate, model.RegistrationFromDate);
            Assert.Equal(viewModel.TeamRegistrationFee, model.TeamRegistrationFee);
            Assert.Equal(viewModel.PlayerRegistrationFee, model.PlayerRegistrationFee);
            Assert.Equal(viewModel.PlayerTradeFee, model.PlayerTradeFee);
        }