public async void RequestVerification_OnSmsSendingFailure_StatusCode500()
        {
            //Arrange
            var form = new VerificationChallengeDto
            {
                PhoneNumber = "1730456789",
                CountryCode = "49"
            };

            var userManagerMock   = MockHelpers.GetMockUserManager();
            var persistenceMock   = new Mock <IIdentityPersistence>();
            var messageSenderMock = new Mock <ISmsSender>();

            messageSenderMock
            .Setup(ms => ms.SendMessageAsync(It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(false);

            var configurationMock = new Mock <IConfigurationService>();

            configurationMock
            .SetupGet(c => c.CountriesBlackList).Returns(new int[] { });

            //Act
            var controller = new VerificationController(_logger, persistenceMock.Object,
                                                        messageSenderMock.Object, configurationMock.Object, userManagerMock.Object);

            var response = await controller.RequestVerification(form);

            //Assert
            Assert.IsType <StatusCodeResult>(response);
        }
        public async void RequestVerification_OnBlackListedCountryCode_BadRequest()
        {
            //Arrange
            var form = new VerificationChallengeDto
            {
                CountryCode = "49",
                PhoneNumber = "1730456789"
            };

            var persistenceMock   = new Mock <IIdentityPersistence>();
            var messageSenderMock = new Mock <ISmsSender>();
            var userManagerMock   = MockHelpers.GetMockUserManager();

            var configurationMock = new Mock <IConfigurationService>();

            configurationMock
            .SetupGet(c => c.CountriesBlackList).Returns(new List <int> {
                1, 12, 49
            });

            //Act
            var controller = new VerificationController(_logger, persistenceMock.Object,
                                                        messageSenderMock.Object, configurationMock.Object, userManagerMock.Object);

            var response = await controller.RequestVerification(form);

            //Assert
            Assert.IsType <BadRequestObjectResult>(response);
        }
        public async void RequestVerification_OnValidForm_Ok()
        {
            //Arrange
            var form = new VerificationChallengeDto
            {
                CountryCode = "49",
                PhoneNumber = "1730456789"
            };

            var userManagerMock = MockHelpers.GetMockUserManager();
            var persistenceMock = new Mock <IIdentityPersistence>();

            persistenceMock
            .Setup(r => r.VerificationTokens
                   .FindByUserAsync(It.IsAny <string>()));

            persistenceMock
            .Setup(r => r.VerificationTokens
                   .AddAsync(It.IsAny <VerificationToken>()))
            .Returns(Task.FromResult(false));

            var messageSenderMock = new Mock <ISmsSender>();

            messageSenderMock
            .Setup(ms => ms.SendMessageAsync(It.IsAny <string>(), It.IsAny <string>()))
            .ReturnsAsync(true);

            var configurationMock = new Mock <IConfigurationService>();

            configurationMock
            .SetupGet(c => c.CountriesBlackList).Returns(new int[] { });

            //Act
            var controller = new VerificationController(_logger, persistenceMock.Object,
                                                        messageSenderMock.Object, configurationMock.Object, userManagerMock.Object);

            var response = await controller.RequestVerification(form);

            //Assert
            Assert.IsType <OkResult>(response);
        }