コード例 #1
0
        public void TestViaXmlProtoSet()
        {
            var model = TypeModel.Create();

            model.Add(typeof(DetectMissing), true);
            DetectMissing dm1 = (DetectMissing)model.DeepClone(new DetectMissing {
                FooSpecified = true, BarSpecified = true
            });

            Assert.IsTrue(dm1.FooSpecified, "FooSpecified:Runtime");
            Assert.IsTrue(dm1.BarSpecified, "BarSpecified:Runtime");

            model.CompileInPlace();
            DetectMissing dm2 = (DetectMissing)model.DeepClone(new DetectMissing {
                FooSpecified = true, BarSpecified = true
            });

            Assert.IsTrue(dm2.FooSpecified, "FooSpecified:CompileInPlace");
            Assert.IsTrue(dm2.BarSpecified, "BarSpecified:CompileInPlace");

            DetectMissing dm3 = (DetectMissing)model.Compile().DeepClone(new DetectMissing {
                FooSpecified = true, BarSpecified = true
            });

            Assert.IsTrue(dm3.FooSpecified, "FooSpecified:Compile");
            Assert.IsTrue(dm3.BarSpecified, "BarSpecified:Compile");

            model.Compile("TestViaXmlProtoSet", "TestViaXmlProtoSet.dll");
            PEVerify.AssertValid("TestViaXmlProtoSet.dll");
        }
コード例 #2
0
ファイル: DetectMissing.cs プロジェクト: izacus/dynabomber
        public void TestViaXmlProtoNotSet()
        {
            DetectMissing dm = Serializer.DeepClone(new DetectMissing());

            Assert.IsFalse(dm.FooSpecified, "FooSpecified");
            Assert.IsFalse(dm.BarSpecified, "BarSpecified");
        }
 public void TestComponentModelNotSet()
 {
     DetectMissing dm    = new DetectMissing();
     var           props = TypeDescriptor.GetProperties(dm);
     //Assert.IsFalse(props["Foo"].ShouldSerializeValue(dm), "Foo");
     //Assert.IsFalse(props["Bar"].ShouldSerializeValue(dm), "Bar");
 }
 public void TestDefaults()
 {
     DetectMissing dm = new DetectMissing();
     //Assert.AreEqual(5, dm.Foo);
     //Assert.AreEqual("abc", dm.Bar);
     //Assert.IsFalse(dm.FooSpecified, "FooSpecified");
     //Assert.IsFalse(dm.BarSpecified, "BarSpecified");
 }
コード例 #5
0
 public void TestDefaults()
 {
     DetectMissing dm = new DetectMissing();
     Assert.AreEqual(5, dm.Foo);
     Assert.AreEqual("abc", dm.Bar);
     Assert.IsFalse(dm.FooSpecified, "FooSpecified");
     Assert.IsFalse(dm.BarSpecified, "BarSpecified");
 }
 public void TestComponentModelSet()
 {
     DetectMissing dm = new DetectMissing {
         FooSpecified = true, BarSpecified = true
     };
     var props = TypeDescriptor.GetProperties(dm);
     //Assert.IsTrue(props["Foo"].ShouldSerializeValue(dm), "Foo");
     //Assert.IsTrue(props["Bar"].ShouldSerializeValue(dm), "Bar");
 }
コード例 #7
0
ファイル: DetectMissing.cs プロジェクト: izacus/dynabomber
        public void TestViaXmlProtoSet()
        {
            DetectMissing dm = Serializer.DeepClone(new DetectMissing
            {
                FooSpecified = true, BarSpecified = true
            });

            Assert.IsTrue(dm.FooSpecified, "FooSpecified");
            Assert.IsTrue(dm.BarSpecified, "BarSpecified");
        }
コード例 #8
0
 public void TestSetValuesToDefaults()
 {
     DetectMissing dm = new DetectMissing();
     dm.Foo = 5;
     dm.Bar = "abc";
     Assert.AreEqual(5, dm.Foo);
     Assert.AreEqual("abc", dm.Bar);
     Assert.IsTrue(dm.FooSpecified, "FooSpecified");
     Assert.IsTrue(dm.BarSpecified, "BarSpecified");
 }
コード例 #9
0
 public void TestSetValuesToNewValues()
 {
     DetectMissing dm = new DetectMissing();
     dm.Foo = 7;
     dm.Bar = "def";
     Assert.AreEqual(7, dm.Foo);
     Assert.AreEqual("def", dm.Bar);
     Assert.IsTrue(dm.FooSpecified, "FooSpecified");
     Assert.IsTrue(dm.BarSpecified, "BarSpecified");
 }
コード例 #10
0
        public void TestSetValuesToNewValues()
        {
            DetectMissing dm = new DetectMissing();

            dm.Foo = 7;
            dm.Bar = "def";
            Assert.AreEqual(7, dm.Foo);
            Assert.AreEqual("def", dm.Bar);
            Assert.IsTrue(dm.FooSpecified, "FooSpecified");
            Assert.IsTrue(dm.BarSpecified, "BarSpecified");
        }
コード例 #11
0
        public void TestSetValuesToDefaults()
        {
            DetectMissing dm = new DetectMissing();

            dm.Foo = 5;
            dm.Bar = "abc";
            Assert.AreEqual(5, dm.Foo);
            Assert.AreEqual("abc", dm.Bar);
            Assert.IsTrue(dm.FooSpecified, "FooSpecified");
            Assert.IsTrue(dm.BarSpecified, "BarSpecified");
        }
コード例 #12
0
        public void TestSetSpecified()
        {
            DetectMissing dm = new DetectMissing();

            dm.FooSpecified = true;
            dm.BarSpecified = true;
            Assert.AreEqual(5, dm.Foo);
            Assert.AreEqual("abc", dm.Bar);
            Assert.IsTrue(dm.FooSpecified, "FooSpecified");
            Assert.IsTrue(dm.BarSpecified, "BarSpecified");
        }
コード例 #13
0
 public void TestViaXmlSerializerNotSet()
 {
     using (MemoryStream ms = new MemoryStream())
     {
         XmlSerializer ser = new XmlSerializer(typeof(DetectMissing));
         ser.Serialize(ms, new DetectMissing());
         ms.Position = 0;
         DetectMissing dm = (DetectMissing)ser.Deserialize(ms);
         Assert.IsFalse(dm.FooSpecified, "FooSpecified");
         Assert.IsFalse(dm.BarSpecified, "BarSpecified");
     }
 }
コード例 #14
0
        public void TestResetSpecified()
        {
            DetectMissing dm = new DetectMissing();

            dm.Foo          = 27;
            dm.Bar          = "ghi";
            dm.FooSpecified = false;
            dm.BarSpecified = false;
            Assert.AreEqual(5, dm.Foo);
            Assert.AreEqual("abc", dm.Bar);
            Assert.IsFalse(dm.FooSpecified, "FooSpecified");
            Assert.IsFalse(dm.BarSpecified, "BarSpecified");
        }
コード例 #15
0
        public void TestComponentModelReset()
        {
            DetectMissing dm = new DetectMissing {
                Foo = 37, Bar = "fgjh"
            };
            var props = TypeDescriptor.GetProperties(dm);

            Assert.IsTrue(props["Foo"].CanResetValue(dm), "Foo");
            Assert.IsTrue(props["Bar"].CanResetValue(dm), "Bar");
            props["Foo"].ResetValue(dm);
            props["Bar"].ResetValue(dm);
            Assert.IsFalse(dm.FooSpecified, "Foo");
            Assert.IsFalse(dm.BarSpecified, "Bar");
        }
コード例 #16
0
 public void TestResetSpecified()
 {
     DetectMissing dm = new DetectMissing();
     dm.Foo = 27;
     dm.Bar = "ghi";
     dm.FooSpecified = false;
     dm.BarSpecified = false;
     Assert.AreEqual(5, dm.Foo);
     Assert.AreEqual("abc", dm.Bar);
     Assert.IsFalse(dm.FooSpecified, "FooSpecified");
     Assert.IsFalse(dm.BarSpecified, "BarSpecified");
 }
コード例 #17
0
 public void TestSetSpecified()
 {
     DetectMissing dm = new DetectMissing();
     dm.FooSpecified = true;
     dm.BarSpecified = true;
     Assert.AreEqual(5, dm.Foo);
     Assert.AreEqual("abc", dm.Bar);
     Assert.IsTrue(dm.FooSpecified, "FooSpecified");
     Assert.IsTrue(dm.BarSpecified, "BarSpecified");
 }
コード例 #18
0
 public void TestComponentModelNotSet()
 {
     DetectMissing dm = new DetectMissing();
     var props = TypeDescriptor.GetProperties(dm);
     Assert.IsFalse(props["Foo"].ShouldSerializeValue(dm), "Foo");
     Assert.IsFalse(props["Bar"].ShouldSerializeValue(dm), "Bar");
 }
コード例 #19
0
 public void TestComponentModelSet()
 {
     DetectMissing dm = new DetectMissing {FooSpecified = true, BarSpecified = true};
     var props = TypeDescriptor.GetProperties(dm);
     Assert.IsTrue(props["Foo"].ShouldSerializeValue(dm), "Foo");
     Assert.IsTrue(props["Bar"].ShouldSerializeValue(dm), "Bar");
 }
コード例 #20
0
 public void TestComponentModelReset()
 {
     DetectMissing dm = new DetectMissing { Foo = 37, Bar = "fgjh" };
     var props = TypeDescriptor.GetProperties(dm);
     Assert.IsTrue(props["Foo"].CanResetValue(dm), "Foo");
     Assert.IsTrue(props["Bar"].CanResetValue(dm), "Bar");
     props["Foo"].ResetValue(dm);
     props["Bar"].ResetValue(dm);
     Assert.IsFalse(dm.FooSpecified, "Foo");
     Assert.IsFalse(dm.BarSpecified, "Bar");
 }