Ejemplo n.º 1
0
        public void TestNonEmptyUriWithDefaultAllCompilationModes()
        {
            var model = TypeModel.Create();

            model.Add(typeof(UriDataWithDefault), true);
            UriDataWithDefault test = new UriDataWithDefault {
                Foo = new Uri("http://test.example.com/demo")
            },
                               defaulted = new UriDataWithDefault {
                Foo = new Uri("http://abc")
            };

            UriDataWithDefault clone = (UriDataWithDefault)model.DeepClone(test);

            Assert.AreEqual(test.Foo, clone.Foo, "Runtime");
            clone = (UriDataWithDefault)model.DeepClone(defaulted);
            Assert.AreEqual(defaulted.Foo, clone.Foo, "Runtime");

            var compiled = model.Compile("TestNonEmptyUriWithDefaultAllCompilationModes", "TestNonEmptyUriWithDefaultAllCompilationModes.dll");

            PEVerify.AssertValid("TestNonEmptyUriWithDefaultAllCompilationModes.dll");
            model.CompileInPlace();
            clone = (UriDataWithDefault)model.DeepClone(test);
            Assert.AreEqual(test.Foo, clone.Foo, "CompileInPlace");
            clone = (UriDataWithDefault)model.DeepClone(defaulted);
            Assert.AreEqual(defaulted.Foo, clone.Foo, "CompileInPlace");

            clone = (UriDataWithDefault)compiled.DeepClone(test);
            Assert.AreEqual(test.Foo, clone.Foo, "Compile");
            clone = (UriDataWithDefault)compiled.DeepClone(defaulted);
            Assert.AreEqual(defaulted.Foo, clone.Foo, "Compile");
        }
Ejemplo n.º 2
0
        public void TestNonEmptyUriWithDefaultAllCompilationModes()
        {
            var model = TypeModel.Create();
            model.Add(typeof(UriDataWithDefault), true);
            UriDataWithDefault test = new UriDataWithDefault { Foo = new Uri("http://test.example.com/demo") },
                defaulted = new UriDataWithDefault { Foo = new Uri("http://abc") };

            UriDataWithDefault clone = (UriDataWithDefault)model.DeepClone(test);
            Assert.AreEqual(test.Foo, clone.Foo, "Runtime");
            clone = (UriDataWithDefault)model.DeepClone(defaulted);
            Assert.AreEqual(defaulted.Foo, clone.Foo, "Runtime");

            var compiled = model.Compile("TestNonEmptyUriWithDefaultAllCompilationModes", "TestNonEmptyUriWithDefaultAllCompilationModes.dll");
            PEVerify.AssertValid("TestNonEmptyUriWithDefaultAllCompilationModes.dll");
            model.CompileInPlace();
            clone = (UriDataWithDefault)model.DeepClone(test);
            Assert.AreEqual(test.Foo, clone.Foo, "CompileInPlace");
            clone = (UriDataWithDefault)model.DeepClone(defaulted);
            Assert.AreEqual(defaulted.Foo, clone.Foo, "CompileInPlace");

            clone = (UriDataWithDefault)compiled.DeepClone(test);
            Assert.AreEqual(test.Foo, clone.Foo, "Compile");
            clone = (UriDataWithDefault)compiled.DeepClone(defaulted);
            Assert.AreEqual(defaulted.Foo, clone.Foo, "Compile");
        }