public async Task Test_GoogleController_NoAuthorizationCode_Fail()
        {
            //Arrange

            //Authorization Code absent
            GoogleAuthModel googleAuthModel = new GoogleAuthModel
            {
                APIKey = "<api key>"
            };

            GoogleClient client = new GoogleClient(this.SecuritySettings, this.MockHttpClient.Object);

            GoogleAuthenticator authenticator = new GoogleAuthenticator(this.SecuritySettings.GoogleSecuritySettings,
                                                                        client);

            var controller = new GoogleController(authenticator);

            try
            {
                //Act
                var result = await controller.Create(googleAuthModel);
            }
            catch (SecurityException ex)
            {
                //Assert
                Assert.IsType <SecurityException>(ex);
                this.MockGoogleClient.Verify(x => x.PostSecurityRequest(googleAuthModel), Times.Never);
            }
        }
        public async Task Test_GoogleController_GoogleAuth_Fail()
        {
            //Arrange

            //Google Client returns IsAuthenticated false
            this.MockGoogleClient = this.InitMockGoogleClient(this.SecuritySettings, false);

            GoogleAuthModel facebookAuthModel = new GoogleAuthModel
            {
                APIKey            = "<api key>",
                AuthorizationCode = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
            };

            GoogleAuthenticator authenticator = new GoogleAuthenticator(this.SecuritySettings.GoogleSecuritySettings,
                                                                        this.MockGoogleClient.Object);

            var controller = new GoogleController(authenticator);

            //Act
            var result = await controller.Create(facebookAuthModel);

            //Assert
            Assert.IsType <BadRequestResult>(result);
            this.MockGoogleClient.Verify(x => x.PostSecurityRequest(facebookAuthModel), Times.Once);
        }
        public async Task Test_GoogleController_NoAPIKey_Fail()
        {
            //Arrange

            //API Key absent
            GoogleAuthModel facebookAuthModel = new GoogleAuthModel
            {
                AuthorizationCode = "<auth_code>"
            };

            GoogleClient client = new GoogleClient(this.SecuritySettings, this.MockHttpClient.Object);

            GoogleAuthenticator authenticator = new GoogleAuthenticator(this.SecuritySettings.GoogleSecuritySettings,
                                                                        client);

            var controller = new GoogleController(authenticator);

            try
            {
                //Act
                var result = await controller.Create(facebookAuthModel);
            }
            catch (SecurityException)
            {
                //Assert
                this.MockGoogleClient.Verify(x => x.PostSecurityRequest(facebookAuthModel), Times.Never);
            }
        }
        public async Task Test_GoogleController_Pass()
        {
            //Arrange
            GoogleAuthModel googleAuthModel = new GoogleAuthModel
            {
                APIKey            = "<api key>",
                AuthorizationCode = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
            };

            GoogleClient client = new GoogleClient(this.SecuritySettings, this.MockHttpClient.Object);

            GoogleAuthenticator authenticator = new GoogleAuthenticator(this.SecuritySettings.GoogleSecuritySettings,
                                                                        client);

            var controller = new GoogleController(authenticator);

            //Act
            var result = await controller.Create(googleAuthModel);

            var googleResponse = ((result as ObjectResult).Value as GoogleResponseModel);

            //Assert
            Assert.IsType <ObjectResult>(result);
            Assert.True(googleResponse.AccessToken.IsValidJwtToken());
            this.MockHttpClient.Verify(x => x.SendAsync <GoogleResponseModel>(It.IsAny <HttpRequestMessage>()), Times.Once);
        }