using System; using Xunit; namespace Octokit.Tests.Authentication { public class CredentialsTests { public class TheAuthenticationTypeProperty { [Fact] public void ReturnsAnonymousForEmptyCtor() { var credentials = Credentials.Anonymous; Assert.Equal(AuthenticationType.Anonymous, credentials.AuthenticationType); } [Fact] public void ReturnsBasicWhenProvidedLoginAndPassword() { var credentials = new Credentials("login", "password"); Assert.Equal(AuthenticationType.Basic, credentials.AuthenticationType); } [Fact] public void ReturnsOAuthWhenProvidedToken() { var credentials = new Credentials("token"); Assert.Equal(AuthenticationType.Oauth, credentials.AuthenticationType); } } public class TheLoginProperty { [Fact] public void IsSetFromCtor() { var credentials = new Credentials("login", "password"); Assert.Equal("login", credentials.Login); } } public class ThePasswordProperty { [Fact] public void IsSetFromCtor() { var credentials = new Credentials("login", "password"); Assert.Equal("password", credentials.Password); } } public class TheCtor { [Fact] public void EnsuresArgumentsNotNullNorEmpty() { Assert.Throws(() => new Credentials(null)); Assert.Throws(() => new Credentials(" ")); Assert.Throws(() => new Credentials(null, "password")); Assert.Throws(() => new Credentials("login", null)); Assert.Throws(() => new Credentials(" ", "Password")); Assert.Throws(() => new Credentials("login", " ")); } } } }