コード例 #1
0
ファイル: Primatives.cs プロジェクト: zjatlas/protobuf-net
        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");
        }
コード例 #2
0
ファイル: Primatives.cs プロジェクト: Erguotou/protobuf-net
        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");
        }