コード例 #1
0
ファイル: MapperTester.cs プロジェクト: prabinv/JuniorMap
            public void Must_assign_all_settable_properties_picked_up_by_convention_in_reverse_case_too()
            {
                var targetFoo = new Foo();
                var sourceBar = new Bar();

                targetFoo.A       = "FooA";
                targetFoo.B       = "FooB";
                targetFoo.C       = 1;
                targetFoo.RefType = null;

                sourceBar.A       = "BarA";
                sourceBar.B       = "BarB";
                sourceBar.C       = 0;
                sourceBar.RefType = new SimpleRefType
                {
                    Id = Guid.NewGuid()
                };

                var systemUnderTest = new DefaultBidirectionalMapper <Foo, Bar>();

                systemUnderTest.Map(sourceBar, targetFoo);

                Assert.That(targetFoo.A, Is.EqualTo(sourceBar.A));
                Assert.That(targetFoo.B, Is.EqualTo(sourceBar.B));
                Assert.That(targetFoo.C, Is.EqualTo(sourceBar.C));
                Assert.That(targetFoo.RefType, Is.Not.Null);
                Assert.That(targetFoo.RefType.Id, Is.Not.Null);
                Assert.That(targetFoo.RefType.Id, Is.EqualTo(sourceBar.RefType.Id));
            }
コード例 #2
0
ファイル: MapperTester.cs プロジェクト: prabinv/JuniorMap
            public void Must_assign_all_settable_properties_picked_up_by_convention()
            {
                var sourceFoo = new Foo();
                var targetBar = new Bar();

                sourceFoo.A       = "SourceA";
                sourceFoo.B       = "SourceB";
                sourceFoo.C       = 1;
                sourceFoo.RefType = new SimpleRefType
                {
                    Id = Guid.NewGuid()
                };

                targetBar.A       = "WrongA";
                targetBar.B       = "WrongB";
                targetBar.C       = 0;
                targetBar.RefType = null;

                var systemUnderTest = new DefaultBidirectionalMapper <Foo, Bar>();

                systemUnderTest.Map(sourceFoo, targetBar);

                Assert.That(targetBar.A, Is.EqualTo(sourceFoo.A));
                Assert.That(targetBar.B, Is.EqualTo(sourceFoo.B));
                Assert.That(targetBar.C, Is.EqualTo(sourceFoo.C));
                Assert.That(targetBar.RefType, Is.Not.Null);
                Assert.That(targetBar.RefType.Id, Is.Not.Null);
                Assert.That(targetBar.RefType.Id, Is.EqualTo(sourceFoo.RefType.Id));
            }