public async void Given_ServiceRequestByIdQuery_When_ExpectedServiceRequestDoesNotExists_Then_ReturnsNull() { // Arrange _serviceRequestRepository .Setup(repo => repo.RetrieveByIdAsync(It.IsAny <Guid>())) .ReturnsAsync((ServiceRequest)null); var query = new QueryServiceRequestById(new Guid()); var target = new QueryServiceRequestByIdHandler(_logger.Object, _serviceRequestRepository.Object); // Act var actual = await target.Handle(query, default); // Assert Assert.Null(actual); }
public async void Given_ServiceRequestByIdQuery_When_ExpectedServiceRequestExists_Then_ReturnsExpectedServiceRequest() { // Arrange var expectedServiceRequest = new ServiceRequest("123", "Turn up the heat!", "Aaron"); _serviceRequestRepository .Setup(repo => repo.RetrieveByIdAsync(It.IsAny <Guid>())) .ReturnsAsync(expectedServiceRequest); var query = new QueryServiceRequestById(new Guid()); var target = new QueryServiceRequestByIdHandler(_logger.Object, _serviceRequestRepository.Object); // Act var actual = await target.Handle(query, default); // Assert Assert.NotNull(actual); Assert.Equal(expectedServiceRequest, actual); }