public async Task ShouldCreateValidParent() { var parentId = Guid.NewGuid(); var command = new CreateParentCommand() { BirthDay = DateTime.UtcNow.AddDays(-3), Id = parentId, LastName = nameof(ShouldCreateValidParent), FirstName = nameof(ShouldCreateValidParent), SecondName = nameof(ShouldCreateValidParent), }; var result = await SendAsync(command); result.Id.Should().Be(parentId); result.CreatedDate.Should().BeCloseTo(DateTime.UtcNow, 10000); }
public async Task <IActionResult> CreateParentAsync([FromBody] CreateParentCommand createParentCommang) { var result = await mediator.Send(createParentCommang); return(Created($"{nameof(Parent)}/{result.Id}", result)); }
public void ShouldThrowValidationException() { var command = new CreateParentCommand(); FluentActions.Invoking(() => SendAsync(command)).Should().Throw <BusinessValidationException>(); }
public async Task <IActionResult> Create(CreateParentCommand command) => await SendAsync(command, resource : "parent");