Example #1
0
        public async Task When_GetPendingEmailsIsCalled_Then_EmailsRepositoryCallsGetPendingEmailsOnce()
        {
            // Given
            var controller = new MailingController(_emailsRepositoryMock.Object, _emailSenderServiceMock.Object);

            // When
            await controller.GetPendingEmails();

            // Then
            _emailsRepositoryMock.Verify(mock => mock.GetPendingEmails(), Times.Once);
        }
Example #2
0
        public async Task When_GetPendingEmailsIsCalled_ButThereAreNoEmailsInPendingState_Then_ControllersGetPendingEmails_Returns_404()
        {
            // Given
            _emailsRepositoryMock
            .Setup(mock => mock.GetPendingEmails())
            .ReturnsAsync(new ActionResponse <IEnumerable <EmailDto> >(new List <EmailDto>(), ErrorResponseMessage));
            var controller = new MailingController(_emailsRepositoryMock.Object, _emailSenderServiceMock.Object);

            // When
            var result = await controller.GetPendingEmails();

            // Then
            var statusCodeResult = result as ObjectResult;

            Assert.Equal(404, statusCodeResult?.StatusCode);
        }