コード例 #1
0
        public void IsValid_ShouldBeFalse_WhenRequiredFieldsAreNotSet()
        {
            var command = new CreateEmailLogCommand();

            var validator = new CreateEmailLogCommandValidator(Context);

            var result = validator.Validate(command);

            result.IsValid.ShouldBe(false);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: Create.cs プロジェクト: dkm8923/WeddingAppCore
        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();
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public async Task <ActionResult <long> > Create(CreateEmailLogCommand command)
 {
     return(await Mediator.Send(command));
 }