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

            // When
            await controller.CreateEmail(_emailDataInputStub);

            // Then
            _emailsRepositoryMock.Verify(mock => mock.CreateEmail(_emailDataInputStub), Times.Once);
        }
Exemple #2
0
        public async Task When_CreateEmailIsCalled_WithInvalidEmailInput_Then_ControllersCreateEmail_Returns_500()
        {
            // Given
            _emailsRepositoryMock
            .Setup(mock => mock.CreateEmail(null))
            .ReturnsAsync(new ActionResponse <bool>(false, ErrorResponseMessage));
            var controller = new MailingController(_emailsRepositoryMock.Object, _emailSenderServiceMock.Object);

            // When
            var result = await controller.CreateEmail(null);

            // Then
            var statusCodeResult = result as ObjectResult;

            Assert.Equal(500, statusCodeResult?.StatusCode);
        }
Exemple #3
0
        public async Task When_CreateEmailIsCalled_WithValidEmailInput_Then_ControllersCreateEmail_Returns_200()
        {
            // Given
            _emailsRepositoryMock
            .Setup(mock => mock.CreateEmail(_emailDataInputStub))
            .ReturnsAsync(new ActionResponse <bool>(true, SuccessResponseMessage));
            var controller = new MailingController(_emailsRepositoryMock.Object, _emailSenderServiceMock.Object);

            // When
            var result = await controller.CreateEmail(_emailDataInputStub);

            // Then
            var statusCodeResult = result as StatusCodeResult;

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