示例#1
0
        public void ClearValues()
        {
            MessageDictionary            target             = this.MessageDescriptions.GetAccessor(this.message);
            IDictionary <string, string> targetAsDictionary = (IDictionary <string, string>)target;

            this.message.Name           = "Andrew";
            this.message.Age            = 15;
            targetAsDictionary["extra"] = "value";
            target.ClearValues();
            Assert.AreEqual(2, target.Count, "Clearing should remove all keys except for declared non-nullable structs.");
            Assert.IsFalse(targetAsDictionary.ContainsKey("extra"));
            Assert.IsNull(this.message.Name);
            Assert.AreEqual(0, this.message.Age);
        }
示例#2
0
        public void IconEncodingDecoding()
        {
            var request = new UIRequest();
            MessageDictionary dictionary = this.MessageDescriptions.GetAccessor(request);

            Assert.IsFalse(dictionary.ContainsKey("icon"));

            Assert.IsFalse(request.Icon.HasValue);
            dictionary["icon"] = "true";
            Assert.IsTrue(request.Icon.Value);

            dictionary.ClearValues();
            request.Icon = true;
            Assert.AreEqual("true", dictionary["icon"]);
        }