public void CreateDefault()
 {
     TestHelpers.EnsureLanguageIsValid();
     UserNameCredentials credentials = new UserNameCredentials();
     Assert.IsNull(credentials.UserName);
     Assert.IsNull(credentials.Identifier);
 }
 public void CreateWithUserName()
 {
     TestHelpers.EnsureLanguageIsValid();
     string name = "JohnDoe";
     UserNameCredentials credentials = new UserNameCredentials(name);
     Assert.AreEqual(name, credentials.UserName);
     Assert.AreEqual(name, credentials.Identifier);
 }
 public void SetAndRetrieveUserName()
 {
     TestHelpers.EnsureLanguageIsValid();
     string name = "JohnDoe";
     UserNameCredentials credentials = new UserNameCredentials();
     Assert.IsNull(credentials.UserName);
     credentials.UserName = name;
     Assert.AreEqual(name, credentials.UserName);
 }
 public void SetAndRetrieveValue()
 {
     TestHelpers.EnsureLanguageIsValid();
     string value1 = "Something";
     string value2 = "Something Else";
     UserNameCredentials credentials = new UserNameCredentials();
     Assert.IsNull(credentials["Value"]);
     credentials["Value"] = value1;
     Assert.AreEqual(value1, credentials["Value"]);
     credentials["Value"] = value2;
     Assert.AreEqual(value2, credentials["Value"]);
     credentials["Value"] = null;
     Assert.IsNull(credentials["Value"]);
 }
 public void PassThroughSerialisation()
 {
     TestHelpers.EnsureLanguageIsValid();
     string name = "JohnDoe";
     string value1 = "Something";
     string value2 = null;
     UserNameCredentials credentials = new UserNameCredentials(name);
     credentials["Value1"] = value1;
     credentials["Value2"] = value2;
     object result = TestHelpers.RunSerialisationTest(credentials);
     Assert.IsNotNull(result);
     Assert.IsInstanceOfType(typeof(UserNameCredentials), result);
     Assert.AreEqual(name, (result as UserNameCredentials).UserName);
     Assert.AreEqual(value1, (result as UserNameCredentials)["Value1"]);
     Assert.AreEqual(value2, (result as UserNameCredentials)["Value2"]);
 }
        public void ListAllCredentials()
        {
            string[] values = { "Value1", "Value2" };
            UserNameCredentials credentials = new UserNameCredentials();
            foreach (string value in values)
            {
                credentials[value] = value;
            }
            string[] allValues = credentials.Credentials;

            string[] expected = { "username", "value1", "value2" };
            Assert.AreEqual(expected.Length, allValues.Length);
            for (int loop = 0; loop < expected.Length; loop++)
            {
                Assert.AreEqual(expected[loop], allValues[loop], string.Format("Value at index {0} does not match", loop));
            }
        }