public async Task GetProductByIdQueryHandlerAsync_WithNullParameter_ThrowsException() { //Arrange GetProductByIdQueryRequest command = null; //Act var actualException = await Assert.ThrowsAsync <Exception>(() => _getProductByIdQueryHandler.Handle(command, new CancellationToken())); //Assert Assert.Equal(MessageConstants.GetProductByIdQueryRequestNull, actualException.Message); }
public async Task GetProductByIdQueryHandlerAsync_WithNullId_ThrowsException() { //Arrange var command = new GetProductByIdQueryRequest { Id = Guid.Empty }; //Act var actualException = await Assert.ThrowsAsync <Exception>(() => _getProductByIdQueryHandler.Handle(command, new CancellationToken())); //Assert Assert.Equal(MessageConstants.GetProductByIdQueryRequestIdNull, actualException.Message); }
public async Task GetProductByIdQueryHandlerAsync_WitNonExistingProduct_ThrowsException() { //Arrange var command = new GetProductByIdQueryRequest { Id = Guid.NewGuid() }; _mockUnitOfWork.Setup(x => x.ProductRepository.GetById(command.Id)).Returns(Task.FromResult <Product>(null)); //Act var actualException = await Assert.ThrowsAsync <Exception>(() => _getProductByIdQueryHandler.Handle(command, new CancellationToken())); //Assert Assert.Equal(MessageConstants.ProductNotFound, actualException.Message); }