public void IsValid_ShouldBeFalse_WhenRequiredFieldsAreNotSet() { var command = new CreateEmailLogCommand(); var validator = new CreateEmailLogCommandValidator(Context); var result = validator.Validate(command); result.IsValid.ShouldBe(false); }
public void IsValid_ShouldBeTrue_WhenRequiredFieldsAreSet() { var command = new CreateEmailLogCommand { EmailId = 1, SentDate = DateTime.Now, SentBy = "UnitTest" }; var validator = new CreateEmailLogCommandValidator(Context); var result = validator.Validate(command); result.IsValid.ShouldBe(true); }
public async Task GivenValidCreateEmailLogCommand_ReturnsSuccessCode() { var client = await _factory.GetAuthenticatedClientAsync(); var command = new CreateEmailLogCommand { EmailId = 1, SentDate = DateTime.Now, SentBy = "Unit Test" }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PostAsync($"/api/EmailLog", content); response.EnsureSuccessStatusCode(); }
public async Task Handle_ShouldPersistEmailLog() { var command = new CreateEmailLogCommand { EmailId = 1, SentDate = DateTime.Now, SentBy = "UnitTest" }; var handler = new CreateEmailLogCommand.CreateEmailLogCommandHandler(Context); var result = await handler.Handle(command, CancellationToken.None); var entity = Context.EmailLogs.Find(result); entity.ShouldNotBeNull(); entity.EmailId.ShouldBe(command.EmailId); entity.SentDate.ShouldBe(command.SentDate); entity.SentBy.ShouldBe(command.SentBy); }
public async Task <ActionResult <long> > Create(CreateEmailLogCommand command) { return(await Mediator.Send(command)); }