public void Setup_token_from_url() { var auth = new VkAuthorization(); var token = new AccessToken(); Assert.That(token.Token, Is.EqualTo(null).Or.EqualTo(string.Empty)); Assert.That(token.UserID, Is.EqualTo(0)); var response = auth.TryToSetupTokenFromUrl(token, exampleUrlCorrectAnswer); Assert.That(response.Successful, Is.True); Assert.That(token.Token, Is.EqualTo(EXAMPLE_TOKEN)); Assert.That(token.UserID, Is.EqualTo(EXAMPLE_USERID)); }
public bool OnWebBrowserNavigated(string url, AuthAction authAction) { Debug.WriteLine($"Browser navigated to url = {url}\nAction = {authAction}"); switch (authAction) { case AuthAction.Authorize: var response = _vkAuthorization.TryToSetupTokenFromUrl(_token, url); if (response.Successful) { _eventAggregator.GetEvent <VkAuthorizationEvents.AcquiredTheToken>().Publish(_token); return(true); } return(false); case AuthAction.Deauthorize: return(true); } return(false); }