コード例 #1
0
        public void TestClientInfoSerialization_Valid()
        {
            var clientInfo = new ClientInfo() { JId = "*****@*****.**", ProtocolVersion = 0, Profiles = new List<Profile>() { Profile.FileServer }, TrustLevel = 2 };

            var xml = clientInfo.Serialize();

            var roundTrip = new ClientInfo();

            Assert.IsTrue(roundTrip.Validate(xml));

            roundTrip.Deserialize(xml);

            Assert.IsNotNull(clientInfo);
            Assert.IsNotNull(roundTrip);

            Assert.AreEqual<string>(clientInfo.JId, roundTrip.JId);
            Assert.AreEqual<int>(clientInfo.ProtocolVersion, roundTrip.ProtocolVersion);
            Assert.AreEqual<int>(clientInfo.TrustLevel, roundTrip.TrustLevel);

            Assert.AreEqual<int>(clientInfo.Profiles.Count, roundTrip.Profiles.Count);

            for (int i = 0; i < clientInfo.Profiles.Count; i++)
            {
                Assert.AreEqual<Profile>(clientInfo.Profiles[i], roundTrip.Profiles[i]);
            }
        }
コード例 #2
0
        public void TestClientInfoSerialization_Invalid()
        {
            var clientInfo = new ClientInfo();

            var xml = clientInfo.Serialize();

            var roundTrip = new ClientInfo();

            Assert.IsFalse(roundTrip.Validate(clientInfo.Serialize()));
        }