コード例 #1
0
        public void TypeWithDictionaryTest()
        {
            var orig = new TypeWithDictionary {
                Data = new Dictionary <string, decimal> {
                    { "abc", 123.45M }
                }
            };
            var model = TypeModel.Create();
            var clone = (TypeWithDictionary)model.DeepClone(orig);

            Assert.Single(clone.Data);
            Assert.Equal(123.45M, clone.Data["abc"]); //, "Runtime");

            model.Compile("TypeWithDictionaryTest", "TypeWithDictionaryTest.dll");
            PEVerify.Verify("TypeWithDictionaryTest.dll");

            model.CompileInPlace();
            clone = (TypeWithDictionary)model.DeepClone(orig);
            Assert.Single(clone.Data);
            Assert.Equal(123.45M, clone.Data["abc"]); //, "Runtime");

            clone = (TypeWithDictionary)model.Compile().DeepClone(orig);
            Assert.Single(clone.Data);
            Assert.Equal(123.45M, clone.Data["abc"]); //, "Runtime");
        }
コード例 #2
0
ファイル: KeyValuePairTests.cs プロジェクト: cash2one/HBNews
 public void ShouldWorkWithAutoLoadDisabledCompile()
 {
     var orig = new TypeWithDictionary { Data = new Dictionary<string, decimal> { { "abc", 123.45M } } };
     var model = TypeModel.Create();
     model.AutoAddMissingTypes = false;
     model.Add(typeof(TypeWithDictionary), true);
     var clone = (TypeWithDictionary)model.Compile().DeepClone(orig);
     Assert.AreEqual(1, clone.Data.Count);
     Assert.AreEqual(123.45M, clone.Data["abc"]);
 }
コード例 #3
0
        public void ShouldWorkWithAutoLoadDisabledAndAddedExplicitlyRuntime()
        {
            var orig = new TypeWithDictionary {
                Data = new Dictionary <string, decimal> {
                    { "abc", 123.45M }
                }
            };
            var model = TypeModel.Create();

            model.AutoAddMissingTypes = false;
            model.Add(typeof(TypeWithDictionary), true);
            model.Add(typeof(KeyValuePair <string, decimal>), true);
            var clone = (TypeWithDictionary)model.DeepClone(orig);

            Assert.Single(clone.Data);
            Assert.Equal(123.45M, clone.Data["abc"]);
        }
コード例 #4
0
        public void ShouldWorkWithAutoLoadDisabledCompile()
        {
            var orig = new TypeWithDictionary {
                Data = new Dictionary <string, decimal> {
                    { "abc", 123.45M }
                }
            };
            var model = TypeModel.Create();

            model.AutoAddMissingTypes = false;
            model.Add(typeof(TypeWithDictionary), true);

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

            PEVerify.Verify("ShouldWorkWithAutoLoadDisabledCompile.dll");

            var clone = (TypeWithDictionary)model.Compile().DeepClone(orig);

            Assert.Single(clone.Data);
            Assert.Equal(123.45M, clone.Data["abc"]);
        }
コード例 #5
0
        public void TypeWithDictionaryTest()
        {
            var orig = new TypeWithDictionary { Data = new Dictionary<string, decimal> { { "abc", 123.45M } } };
            var model = TypeModel.Create();
            var clone = (TypeWithDictionary)model.DeepClone(orig);
            Assert.AreEqual(1, clone.Data.Count);
            Assert.AreEqual(123.45M, clone.Data["abc"], "Runtime");

            model.Compile("TypeWithDictionaryTest", "TypeWithDictionaryTest.dll");
            PEVerify.Verify("TypeWithDictionaryTest.dll");

            model.CompileInPlace();
            clone = (TypeWithDictionary)model.DeepClone(orig);
            Assert.AreEqual(1, clone.Data.Count);
            Assert.AreEqual(123.45M, clone.Data["abc"], "Runtime");

            clone = (TypeWithDictionary)model.Compile().DeepClone(orig);
            Assert.AreEqual(1, clone.Data.Count);
            Assert.AreEqual(123.45M, clone.Data["abc"], "Runtime");
        }
コード例 #6
0
 public void ShouldWorkWithAutoLoadDisabledCompile()
 {
     var orig = new TypeWithDictionary { Data = new Dictionary<string, decimal> { { "abc", 123.45M } } };
     var model = TypeModel.Create();
     model.AutoAddMissingTypes = false;
     model.Add(typeof(TypeWithDictionary), true);
     var clone = (TypeWithDictionary)model.Compile().DeepClone(orig);
     Assert.AreEqual(1, clone.Data.Count);
     Assert.AreEqual(123.45M, clone.Data["abc"]);
 }