Пример #1
0
        public async Task <ActionResult> Update(int id, UpdateTermCommand command)
        {
            if (id != command.Id)
            {
                return(BadRequest());
            }

            await Mediator.Send(command);

            return(NoContent());
        }
Пример #2
0
        public void ShouldRequireValidTermId()
        {
            var command = new UpdateTermCommand
            {
                Id         = 99,
                TermText   = "Test Term",
                Definition = "Test Definition"
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <NotFoundException>();
        }
Пример #3
0
        public async Task ShouldUpdateTerm()
        {
            var command = new CreateTermCommand
            {
                TermText   = "Test Term",
                Definition = "Test Definition"
            };

            var termCreated = await SendAsync(command);

            var updateCommand = new UpdateTermCommand
            {
                Id         = termCreated.Id,
                TermText   = "Test Term Updated",
                Definition = "Test Definition updated"
            };

            await SendAsync(updateCommand);

            var updatedTerm = await FindAsync <Domain.Entities.Term>(termCreated.Id);

            updatedTerm.TermText.Should().Be(updateCommand.TermText);
            updatedTerm.LastModified.Should().NotBeNull();
        }