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); }
public UpdateAuthorCommandHandlerTests() { _authorRepository = new Mock <IAuthorRepository>(); IValidator <UpdateAuthorCommand> updateAuthorCommandValidator = new UpdateAuthorCommandValidator(_authorRepository.Object); _updateAuthorCommandHandler = new UpdateAuthorCommandHandler(updateAuthorCommandValidator, _authorRepository.Object); }
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); }