public void Must_perform_acceptably() { 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.likeA = "WrongA"; targetBar.likeB = "WrongB"; targetBar.likeC = 0; targetBar.likeRefType = null; var systemUnderTest = new FooBarMapper(); var milliseconds = (long)StopwatchContext.Timed(() => { for (int i = 0; i < 10000000; i++) { systemUnderTest.Map(sourceFoo, targetBar); } }).TotalMilliseconds; Console.WriteLine(milliseconds); }
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.likeA = "BarA"; sourceBar.likeB = "BarB"; sourceBar.likeC = 0; sourceBar.likeRefType = new SimpleRefType { Id = Guid.NewGuid() }; var systemUnderTest = new FooBarMapper(); systemUnderTest.Map(sourceBar, targetFoo); Assert.That(targetFoo.A, Is.EqualTo(sourceBar.likeA)); Assert.That(targetFoo.B, Is.EqualTo(sourceBar.likeB)); Assert.That(targetFoo.C, Is.EqualTo(sourceBar.likeC)); Assert.That(targetFoo.RefType, Is.Not.Null); Assert.That(targetFoo.RefType.Id, Is.Not.Null); Assert.That(targetFoo.RefType.Id, Is.EqualTo(sourceBar.likeRefType.Id)); }
public void Must_assign_all_settable_properties() { 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.likeA = "WrongA"; targetBar.likeB = "WrongB"; targetBar.likeC = 0; targetBar.likeRefType = null; var systemUnderTest = new FooBarMapper(); systemUnderTest.Map(sourceFoo, targetBar); Assert.That(targetBar.likeA, Is.EqualTo(sourceFoo.A)); Assert.That(targetBar.likeB, Is.EqualTo(sourceFoo.B)); Assert.That(targetBar.likeC, Is.EqualTo(sourceFoo.C)); Assert.That(targetBar.likeRefType, Is.Not.Null); Assert.That(targetBar.likeRefType.Id, Is.Not.Null); Assert.That(targetBar.likeRefType.Id, Is.EqualTo(sourceFoo.RefType.Id)); }
public void Must_assign_all_configured_properties_and_invoke_action_delegates() { var sourceFoo = new Foo(); var targetBar = new Bar(); sourceFoo.A = "SourceA"; sourceFoo.B = "SourceB"; sourceFoo.C = 1; sourceFoo.RefType = new SimpleRefType { Id = Guid.NewGuid() }; sourceFoo.SomeString = "FooSomeString"; targetBar.likeA = "WrongA"; targetBar.likeB = "WrongB"; targetBar.likeC = 0; targetBar.likeRefType = null; var systemUnderTest = new FooBarMapper(); systemUnderTest.Map(sourceFoo, targetBar); Assert.That(targetBar.likeA, Is.EqualTo(sourceFoo.A)); Assert.That(targetBar.likeB, Is.EqualTo(sourceFoo.B)); Assert.That(targetBar.likeC, Is.EqualTo(sourceFoo.C)); Assert.That(targetBar.likeRefType, Is.Not.Null); Assert.That(targetBar.SomeString, Is.EqualTo(sourceFoo.SomeString)); Assert.That(targetBar.likeRefType.Id, Is.Not.Null); Assert.That(targetBar.likeRefType.Id, Is.EqualTo(sourceFoo.RefType.Id)); Assert.That(targetBar.GetDirty(), Is.True); Assert.That(targetBar.CoordinateX, Is.EqualTo(9)); Assert.That(targetBar.CoordinateY, Is.EqualTo(8)); Assert.That(targetBar.CoordinateZ, Is.EqualTo(7)); Assert.That(targetBar.ToIgnoreChain1, Is.Null); Assert.That(targetBar.ToIgnoreChain2, Is.Null); Assert.That(targetBar.ToIgnoreChain3, Is.Null); }