예제 #1
0
        public void Flattening()
        {
            var unflat = new Foo
            {
                Name = "foo",
                Foo1 = new Foo
                {
                    Name = "abc",
                    Foo2 = new Foo {
                        Foo1 = new Foo {
                            Name = "inner"
                        }
                    }
                },
                Foo2 = new Foo {
                    Name = "123", NameZype = "aaa"
                },
            };

            var flat = new FlatFoo();

            flat.InjectFrom <FlatLoopInjection>(unflat);

            flat.Foo2NameZype.IsEqualTo("aaa");
        }
예제 #2
0
        public void GenericUnflatTest()
        {
            var flat = new FlatFoo { Foo1Age = "16" };
            var foo = new Foo();

            foo.InjectFrom<IntToStrUnflat>(flat);
            foo.Foo1.Age.IsEqualTo(16);
        }
예제 #3
0
        public void GenericFlatTest()
        {
            var foo = new Foo { Foo1 = new Foo { Age = 18 } };
            var flat = new FlatFoo();

            flat.InjectFrom<IntToStringFlat>(foo);
            flat.Foo1Age.IsEqualTo("18");
        }
예제 #4
0
        public void GenericUnflatTest()
        {
            var flat = new FlatFoo {
                Foo1Age = "16"
            };
            var foo = new Foo();

            foo.InjectFrom <IntToStrUnflat>(flat);
            foo.Foo1.Age.IsEqualTo(16);
        }
예제 #5
0
        public void GenericFlatTest()
        {
            var foo = new Foo {
                Foo1 = new Foo {
                    Age = 18
                }
            };
            var flat = new FlatFoo();

            flat.InjectFrom <IntToStringFlat>(foo);
            flat.Foo1Age.IsEqualTo("18");
        }
예제 #6
0
        public void Unflattening()
        {
            var flat = new FlatFoo
                           {
                               Foo1Foo2Foo1Name = "cool",
                               Foo1Name = "abc",
                               Foo2Name = "123",
                           };

            var unflat = new Foo();

            unflat.InjectFrom<UnflatLoopInjection>(flat);

            unflat.Foo1.Foo2.Foo1.Name.IsEqualTo("cool");
            unflat.Foo1.Name.IsEqualTo("abc");
            unflat.Foo2.Name.IsEqualTo("123");
        }
예제 #7
0
        public void Unflattening()
        {
            var flat = new FlatFoo
            {
                Foo1Foo2Foo1Name = "cool",
                Foo1Name         = "abc",
                Foo2Name         = "123",
            };

            var unflat = new Foo();

            unflat.InjectFrom <UnflatLoopInjection>(flat);

            unflat.Foo1.Foo2.Foo1.Name.IsEqualTo("cool");
            unflat.Foo1.Name.IsEqualTo("abc");
            unflat.Foo2.Name.IsEqualTo("123");
        }
예제 #8
0
        public void ObjectFlatTest()
        {
            var unflat = (object)new
            {
                Parent = (object)new Foo
                {
                    b    = true,
                    Name = "v"
                }
            };

            var flat = new FlatFoo();

            flat.InjectFrom <FlatBoolToString>(unflat);
            flat.Parentb.IsEqualTo("True");
            flat.Bool.IsEqualTo(null);
        }
예제 #9
0
        public void Flattening()
        {
            var unflat = new Foo
                             {
                                 Name = "foo",
                                 Foo1 = new Foo
                                            {
                                                Name = "abc",
                                                Foo2 = new Foo { Foo1 = new Foo { Name = "inner" } }
                                            },
                                 Foo2 = new Foo { Name = "123", NameZype = "aaa" },
                             };

            var flat = new FlatFoo();

            flat.InjectFrom<FlatLoopInjection>(unflat);

            flat.Foo2NameZype.IsEqualTo("aaa");
        }
예제 #10
0
        public void GenericFlatTest()
        {
            var unflat = new Foo
            {
                Parent = new Foo
                {
                    _a   = "aaa",
                    a    = 23,
                    b    = true,
                    Name = "v"
                }
            };

            var flat = new FlatFoo();

            flat.InjectFrom <FlatBoolToString>(unflat);
            flat.Parentb.IsEqualTo("True");
            flat.Bool.IsEqualTo(null);
        }
예제 #11
0
        public void FlatteningTest()
        {
            var unflat = new Foo
            {
                Parent = new Foo
                {
                    _a   = "aaa",
                    a    = 23,
                    b    = true,
                    Name = "v"
                }
            };

            var flat = new FlatFoo();

            flat.InjectFrom <FlatLoopInjection>(unflat);
            flat.Parent_a.IsEqualTo(unflat.Parent._a);
            flat.Parenta.IsEqualTo(unflat.Parent.a);
            flat.Parentb.IsEqualTo(null);
            flat.ParentName.IsEqualTo(unflat.Parent.Name);
            flat.ParentParentName.IsEqualTo(null);
            flat.oO.IsEqualTo(null);
            flat.d.IsEqualTo(null);
        }
예제 #12
0
        public void TestSimpleMappingScenarioWithSampleSourceObject()
        {
            var flatfoo = new FlatFoo
            {
                I = 1,
                A = DateTime.Today,
                B = "B"
            };

            Foo foo = MapperFactory.GetBidirectionalMapper<Foo>(flatfoo).ToNested(flatfoo);

            Check.That(foo.I).IsEqualTo(1);
            Check.That(foo.N.A).IsEqualTo(DateTime.Today);
            Check.That(foo.N.B).IsEqualTo("B");
        }
예제 #13
0
        public void TestSimpleMappingScenarioWithProvidedProperties()
        {
            var props = new List<PropertyBasicInfo>
            {
                new PropertyBasicInfo("I", typeof (int)),
                new PropertyBasicInfo("A", typeof (DateTime)),
                new PropertyBasicInfo("B", typeof (string))
            };

            var flatfoo = new FlatFoo
            {
                I = 1,
                A = DateTime.Today,
                B = "B"
            };

            Foo foo = MapperFactory.GetBidirectionalMapper<Foo>(props).ToNested(flatfoo);

            Check.That(foo.I).IsEqualTo(1);
            Check.That(foo.N.A).IsEqualTo(DateTime.Today);
            Check.That(foo.N.B).IsEqualTo("B");
        }