public async Task When_GetEmailStatusIsCalled_Then_EmailsRepositoryCallsGetEmailStatusOnce() { // Given var controller = new MailingController(_emailsRepositoryMock.Object, _emailSenderServiceMock.Object); // When await controller.GetEmailStatus(_emailId); // Then _emailsRepositoryMock.Verify(mock => mock.GetEmailStatus(_emailId), Times.Once); }
public async Task When_GetEmailStatusIsCalled_WithInvalidEmailId_Then_ControllersGetEmailStatus_Returns_404() { // Given _emailsRepositoryMock .Setup(mock => mock.GetEmailStatus(Guid.Empty)) .ReturnsAsync(new ActionResponse <string>(string.Empty, ErrorResponseMessage)); var controller = new MailingController(_emailsRepositoryMock.Object, _emailSenderServiceMock.Object); // When var result = await controller.GetEmailStatus(_emailId); // Then var statusCodeResult = result as ObjectResult; Assert.Equal(404, statusCodeResult?.StatusCode); }
public async Task When_GetEmailStatusIsCalled_WithValidEmailId_Then_ControllersGetEmailStatus_Returns_200() { const string pendingStatus = "Pending"; // Given _emailsRepositoryMock .Setup(mock => mock.GetEmailStatus(_emailId)) .ReturnsAsync(new ActionResponse <string>(pendingStatus, SuccessResponseMessage)); var controller = new MailingController(_emailsRepositoryMock.Object, _emailSenderServiceMock.Object); // When var result = await controller.GetEmailStatus(_emailId); // Then var statusCodeResult = result as ObjectResult; Assert.Equal(200, statusCodeResult?.StatusCode); }