示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }