public void ExternalLoginCallback_RedirectsTo_ExternalLoginConfirm_WhenUserIsNew()
        {
            // Arrange
            var mocks = new OAuthMocks();
            var controller = GetController(mocks);
            var extraData = new Dictionary<string, string> {{"accesstoken", "providerAccessToken"}};
            var authResult = new AuthenticationResult(true, PROVIDER, PROVIDER_USERID, USERNAME, extraData);
            var mxClient = new MxClient(new InMemoryOAuthTokenManager("a", "b"));

            mocks.Response.Setup(r => r.ApplyAppPathModifier(It.IsAny<string>())).Returns(RETURN_URL);
            mocks.OAuthWebSecurity.Setup(ows => ows.VerifyAuthentication(It.IsAny<string>())).Returns(authResult);
            mocks.OAuthWebSecurity.Setup(ows => ows.Login(PROVIDER, PROVIDER_USERID, false)).Returns(false);
            mocks.Identity.Setup(i => i.IsAuthenticated).Returns(false);

            mocks.OAuthWebSecurity.Setup(ows => ows.SerializeProviderUserId(PROVIDER, PROVIDER_USERID)).Returns(PROVIDER_USERID);
            mocks.OAuthWebSecurity.Setup(ows => ows.GetOAuthClientData(PROVIDER)).Returns(new AuthenticationClientData(mxClient, PROVIDER_DISPLAY_NAME, null));

            // Act
            var result = controller.ExternalLoginCallback(RETURN_URL) as ViewResult;

            // Assert
            Assert.NotNull(result, "result");
            Assert.AreEqual(result.ViewBag.ProviderDisplayName, PROVIDER_DISPLAY_NAME);

            var model = result.Model as RegisterExternalLoginModel;
            Assert.NotNull(model, "result");
            Assert.AreEqual(model.UserName, authResult.UserName);
            Assert.AreEqual(model.ExternalLoginData, authResult.ProviderUserId);
            Assert.AreEqual(model.AccessToken, "providerAccessToken");
        }
 public void TokenManager()
 {
     var tokenManager = new InMemoryOAuthTokenManager("a", "b");
     var mxClient = new MxClient(tokenManager);
     Assert.NotNull(mxClient, "mxClient");
     var tokens = mxClient.TokenManager;
     Assert.NotNull(tokens, "tokens");
 }