public void IsValid_ShouldBeFalse_WhenRequiredFieldsAreNotSet()
        {
            var command = new CreateGuestBookEntryCommand();

            var validator = new CreateGuestBookEntryCommandValidator(Context);

            var result = validator.Validate(command);

            result.IsValid.ShouldBe(false);
        }
        public void IsValid_ShouldBeTrue_WhenRequiredFieldsAreSet()
        {
            var command = new CreateGuestBookEntryCommand
            {
                Name = "Test Name",
                Entry = "Test Entry"
            };

            var validator = new CreateGuestBookEntryCommandValidator(Context);

            var result = validator.Validate(command);

            result.IsValid.ShouldBe(true);
        }
Пример #3
0
        public async Task GivenValidCreateGuestBookEntryCommand_ReturnsSuccessCode()
        {
            var client = await _factory.GetAuthenticatedClientAsync();

            var command = new CreateGuestBookEntryCommand
            {
                Name  = "Test Name",
                Entry = "Test Entry"
            };

            var content = IntegrationTestHelper.GetRequestContent(command);

            var response = await client.PostAsync($"/api/GuestBookEntry", content);

            response.EnsureSuccessStatusCode();
        }
        public async Task Handle_ShouldPersistGuestBookEntry()
        {
            var command = new CreateGuestBookEntryCommand
            {
                Name  = "Test Name",
                Entry = "Test Entry"
            };

            var handler = new CreateGuestBookEntryCommand.CreateGuestBookEntryCommandHandler(Context);

            var result = await handler.Handle(command, CancellationToken.None);

            var entity = Context.GuestBookEntries.Find(result);

            entity.ShouldNotBeNull();
            entity.Name.ShouldBe(command.Name);
            entity.Entry.ShouldBe(command.Entry);
        }
 public async Task <ActionResult <long> > Create(CreateGuestBookEntryCommand command)
 {
     return(await Mediator.Send(command));
 }