-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0c666b
commit cab9bfa
Showing
3 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MapperFixture>, IDisposable | ||
{ | ||
private readonly MapperFixture fixture; | ||
public ComplexDomainObjectTests(MapperFixture fix) | ||
{ | ||
fixture = fix; | ||
|
||
} | ||
[Fact] | ||
public void ShouldMapComplexObject() | ||
{ | ||
|
||
var testobj = Builder<ComplexDomainObject>.CreateNew().Build(); | ||
var ent = Mapper.Map<SimpleEntity>(testobj); | ||
|
||
Assert.NotNull(ent); | ||
Assert.IsAssignableFrom<SimpleEntity>(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<SimpleDomainObject>.CreateNew().Build(); | ||
|
||
var ent = Mapper.Map<SimpleEntity>(testobj); | ||
|
||
Assert.NotNull(ent); | ||
Assert.IsAssignableFrom<SimpleEntity>(ent); | ||
Assert.Equal(ent.Name, testobj.Name); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
fixture?.Dispose(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MapperTests.MapperFixture>(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
|
||
// Do "global" teardown here; Only called once. | ||
} | ||
} | ||
|
||
} |