diff --git a/README.md b/README.md index c2b8abb..f25d98f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Threenine.Map -[![Build status](https://ci.appveyor.com/api/projects/status/6ob8lbutfecvi5n3/branch/master?svg=true)](https://ci.appveyor.com/project/garywoodfine/reflectmap/branch/master) [![NuGet](http://img.shields.io/nuget/v/Threenine.Data.svg)](https://www.nuget.org/packages/Threenine.Map/) [![Twitter Follow](https://img.shields.io/twitter/follow/threenine39.svg?style=social?maxAge=2592000)](https://twitter.com/threenine39) +[![Build status](https://ci.appveyor.com/api/projects/status/6ob8lbutfecvi5n3/branch/master?svg=true)](https://ci.appveyor.com/project/garywoodfine/reflectmap/branch/master) [![NuGet](http://img.shields.io/nuget/v/Threenine.Map.svg)](https://www.nuget.org/packages/Threenine.Map/) [![Twitter Follow](https://img.shields.io/twitter/follow/threenine39.svg?style=social?maxAge=2592000)](https://twitter.com/threenine39) Handy utility library to help with the implementation of AutoMapper in software projects. diff --git a/UnitTests/MapperTests/ComplexDomainObjectTests.cs b/UnitTests/MapperTests/ComplexDomainObjectTests.cs new file mode 100644 index 0000000..e69a1d7 --- /dev/null +++ b/UnitTests/MapperTests/ComplexDomainObjectTests.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Text; +using AutoMapper; +using DomainObjects; +using EntityObjects; +using FizzWare.NBuilder; +using Threenine.Map; +using Xunit; + +namespace MapperTests +{ + public class ComplexDomainObjectTests : IClassFixture, IDisposable + { + private readonly MapperFixture fixture; + public ComplexDomainObjectTests(MapperFixture fix) + { + fixture = fix; + + } + [Fact] + public void ShouldMapComplexObject() + { + + var testobj = Builder.CreateNew().Build(); + var ent = Mapper.Map(testobj); + + Assert.NotNull(ent); + Assert.IsAssignableFrom(ent); + Assert.Equal(ent.Name, string.Concat(testobj.Firstname, " ", testobj.LastName)); + Assert.Equal(ent.Description, string.Concat(testobj.Title, " ", testobj.Summary)); + } + + [Fact] + public void ShouldMapSimpleObject() + { + + var testobj = Builder.CreateNew().Build(); + + var ent = Mapper.Map(testobj); + + Assert.NotNull(ent); + Assert.IsAssignableFrom(ent); + Assert.Equal(ent.Name, testobj.Name); + } + + public void Dispose() + { + fixture?.Dispose(); + } + } +} diff --git a/UnitTests/MapperTests/MapperFixture.cs b/UnitTests/MapperTests/MapperFixture.cs new file mode 100644 index 0000000..6139e0e --- /dev/null +++ b/UnitTests/MapperTests/MapperFixture.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Text; +using AutoMapper; +using Threenine.Map; +using Xunit; + +namespace MapperTests +{ + public class MapperFixture : IDisposable + { + public MapperFixture() + { + MapConfigurationFactory.Scan(); + } + + public void Dispose() + { + + // Do "global" teardown here; Only called once. + } + } + +}