예제 #1
0
        public async Task <IActionResult> Modify(ModifyTournamentFormatCommand command)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(command));
            }

            await this.Mediator.Send(command);

            return(this.RedirectToAction(nameof(Index)));
        }
예제 #2
0
        public async Task Handle_GivenValidRequest_ShouldModifyEntity()
        {
            // Arrange
            var sut = new ModifyTournamentFormatCommandHandler(deletableEntityRepository);

            var tournamentFormatId = 2;
            var command            = new ModifyTournamentFormatCommand
            {
                Id          = tournamentFormatId,
                Name        = "9v9",
                Description = "Changed description from test",
            };

            // Act
            var id = await sut.Handle(command, It.IsAny <CancellationToken>());

            // Assert
            var desiredEntity = this.deletableEntityRepository.AllAsNoTracking().SingleOrDefault(x => x.Id == tournamentFormatId);

            id.ShouldBe(tournamentFormatId);
            desiredEntity.Name.ShouldBe("9v9");
            desiredEntity.Description.ShouldBe("Changed description from test");
        }