public async Task ShouldRequireFutureDateAsync() { var userId = await RunAsDefaultUserAsync(); var command = new CreateFormCommand { Name = "Urim", Company = "Google", Email = "*****@*****.**", Telephone = "+38349123456", Appointment = DateTime.UtcNow.AddDays(-1), }; FluentActions.Invoking(async() => { await SendAsync(command); }).Should().Throw <ValidationException>(); command.Appointment = DateTime.UtcNow.AddMinutes(80); var id = await SendAsync(command); id.Should <Guid>(); id.Should().NotBe(Guid.Empty); Form form = await FindAsync <Form>(id); form.Should().NotBeNull(); form.Name.Should().Be(command.Name); form.Telephone.Should().Be(command.Telephone); form.Appointment.Should().Be(command.Appointment); form.Email.Should().Be(command.Email); form.Date.Should().BeCloseTo(DateTime.Now, 10000); }
//[TestCase("asd", ExpectedResult = typeof(ValidationException))] public async Task ShouldRequireValidPhoneNumberAsync(string number) { var userId = await RunAsDefaultUserAsync(); var command = new CreateFormCommand { Name = "Urim", Company = "Google", Email = "*****@*****.**", Telephone = number, Appointment = DateTime.UtcNow.AddDays(1), }; var id = await SendAsync(command); id.Should <Guid>(); id.Should().NotBe(Guid.Empty); Form form = await FindAsync <Form>(id); form.Should().NotBeNull(); form.Name.Should().Be(command.Name); form.Telephone.Should().Be(command.Telephone); form.Appointment.Should().Be(command.Appointment); form.Email.Should().Be(command.Email); form.Date.Should().BeCloseTo(DateTime.Now, 10000); }
public void ShouldRequireAllFields() { var command = new CreateFormCommand { Name = "Urim" }; FluentActions.Invoking(async() => { await SendAsync(command); }).Should().Throw <ValidationException>(); }
public async Task <IActionResult> PostForm([FromBody] CreateFormCommand form) { Guid guid = await Mediator.Send(form); return(CreatedAtAction("GetForm", new { id = guid }, form)); }
public async Task <ApiResult> CreateForm([FromBody] CreateFormCommand command) { return(await _sender.Send(command)); }