public void Should_Update_When_Command_Is_Valid()
        {
            //Arrange
            var author = new UpdateAuthorCommand {
                Id = Guid.NewGuid(), Name = "Robert Cecil Martin"
            };

            //Act
            _updateAuthorCommandHandler.Handle(author);

            //Assert
            _authorRepository.Verify(r => r.Update(It.IsAny <Domain.Entities.Author>()), Times.Once);
        }
コード例 #2
0
        public async Task UpdateAuthorCommandHandler_WithExperiences_UpdatesAuthor()
        {
            await AddAuthor();

            var image = await AddImage();

            var experiences   = new List <ExperienceDto>();
            var experienceDto = new ExperienceDto()
            {
                Color   = "#000000",
                Name    = "Testfile",
                ImageId = image.Id
            };

            experiences.Add(experienceDto);

            var message = new UpdateAuthorCommand()
            {
                FirstName = "Test", LastName = "Test", About = "Test", Experiences = experiences
            };
            var handler = new UpdateAuthorCommandHandler(TestContext.CreateHandlerContext <AuthorViewModel>(RequestDbContext, CreateMapper()), _authorService);

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

            Assert.Equal("Testfile", result.Experiences.First().Name = experienceDto.Name);
        }
コード例 #3
0
        public async Task UpdateAuthorCommandHandler_WithImage_ReturnsAuthor()
        {
            await AddAuthor();

            var image = await AddImage();

            var handler = new UpdateAuthorCommandHandler(TestContext.CreateHandlerContext <AuthorViewModel>(RequestDbContext, CreateMapper()), _authorService);

            var message = new UpdateAuthorCommand()
            {
                FirstName = "Tom",
                LastName  = "Bina",
                About     = "About me",
                ImageId   = image.Id
            };

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

            Assert.NotNull(result.Image);
        }