public async Task Get_Category_Detail_ById_Success() { var handler = new GetCategoryDetailQueryHandler(_mockCategoryRepository.Object, _mapper); var result = await handler.Handle(new GetCategoryDetailQuery() { CategoryId = RepositoryMock.CategoryIdNeed }, CancellationToken.None); result.Should().NotBe(null); result.CategoryId.Should().Be(RepositoryMock.CategoryIdNeed); }
public async Task GetCategoryDetailTest() { var queryHandler = new GetCategoryDetailQueryHandler(_context, _mapper); var result = await queryHandler.Handle(new GetCategoryDetailQuery() { Id = 1 }, CancellationToken.None); result.ShouldBeOfType <CategoryDetailVM>(); result.Id.ShouldBe(1); }
public Task Get_Category_Detail_ById_Not_Found() { var handler = new GetCategoryDetailQueryHandler(_mockCategoryRepository.Object, _mapper); Func <Task> action = async() => { var result = await handler.Handle(new GetCategoryDetailQuery() { CategoryId = Guid.Empty }, CancellationToken.None); }; action.Should().ThrowAsync <NotFoundException>(); return(Task.CompletedTask); }
public async Task GetCategoryDetailTest_ShouldThrowNotFoundException() { // Arrange var sut = new GetCategoryDetailQueryHandler(_context, _mapper); var categoryId = 100; // Act var ex = await Assert.ThrowsAsync <NotFoundException>(() => sut.Handle(new GetCategoryDetailQuery { Id = categoryId }, CancellationToken.None)); // Assert Assert.IsType <NotFoundException>(ex); }
public async Task GetCategoryDetailTest_ShouldReturnCorrectEntity() { // Arrange var sut = new GetCategoryDetailQueryHandler(_context, _mapper); var categoryId = 1; // Act var result = await sut.Handle(new GetCategoryDetailQuery { Id = categoryId }, CancellationToken.None); // Assert Assert.IsType <CategoryDetailDto>(result); Assert.Equal(categoryId, result.Id); Assert.Equal("Test Category 1", result.Name); Assert.Equal("test-category-1", result.Slug); Assert.Equal(2, result.TotalPosts); }