public bool IsAuthenticated()
{
// this doesn't account for auth revoke on the server but its much faster
// than doing the API hit.
var authType = client.Connection.Credentials?.AuthenticationType ?? AuthenticationType.Anonymous;
return authType != AuthenticationType.Anonymous;
}
public void ReturnsFalseWhenAuthenicationTypeIsAnonymous() { var connection = Substitute.For<IConnection>(); connection.Credentials=Credentials.Anonymous; var gitHubClient = Substitute.For<IGitHubClient>(); gitHubClient.Connection.Returns(connection); var client = new SimpleApiClient( "https://github.com/github/visualstudio", gitHubClient, null, null); var result = client.IsAuthenticated(); Assert.False(result); }