public void SaveAndReadTest()
        {
            LoginElement login = new LoginElement("jdoe");
            login.Admin = true;
            login.HashFunctionName = "SHA-1";
            entry.Login = login;

            QuotaElement quota = new QuotaElement(2048);
            entry.Quota = quota;

            NameElement name = new NameElement("Doe", "John");
            entry.Name = name;

            StringBuilder sb = new StringBuilder();
            XmlWriter writer = new XmlTextWriter(new StringWriter(sb));
            entry.SaveToXml(writer);
            writer.Close();

            XmlDocument document = new XmlDocument();
            document.LoadXml(sb.ToString());

            UserEntry newEntry = new UserEntry();
            foreach (XmlNode node in document.FirstChild.ChildNodes)
            {
                ExtensionElementEventArgs args = new ExtensionElementEventArgs();
                args.ExtensionElement = node;
                args.Base = newEntry;
                newEntry.Parse(args, new AtomFeedParser());
            }

            Assert.AreEqual(login.UserName, newEntry.Login.UserName,
                "Parsed entry should have same username as original entry");
            Assert.IsTrue(newEntry.Login.Admin,
                "Parsed entry should have admin property set to true");
            Assert.AreEqual(login.HashFunctionName, newEntry.Login.HashFunctionName,
                "Parsed entry should have same hash function name as original entry");
            Assert.AreEqual(quota.Limit, newEntry.Quota.Limit,
                "Parsed entry should have same quota as original entry");
            Assert.AreEqual(name.FamilyName, newEntry.Name.FamilyName,
                "Parsed entry should have same family name as original entry");
            Assert.AreEqual(name.GivenName, newEntry.Name.GivenName,
                "Parsed entry should have same given name as original entry");
        }
Пример #2
0
 public void Init()
 {
     quota = new QuotaElement(0);
     rng = new Random();
 }
 public void SetQuotaTest()
 {
     QuotaElement quota = new QuotaElement(2048);
     entry.Quota = quota;
     Assert.AreEqual(quota, entry.Quota, "Quota should be updated after setting");
 }