-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated TypeCreatorBase to include logging of type mapping
- Loading branch information
1 parent
517514c
commit 747747f
Showing
11 changed files
with
135 additions
and
7 deletions.
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
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,7 @@ | ||
namespace ModelBuilder.UnitTests.Models | ||
{ | ||
public interface IItem | ||
{ | ||
void DoSomething(); | ||
} | ||
} |
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,10 @@ | ||
namespace ModelBuilder.UnitTests.Models | ||
{ | ||
public class Item : IItem | ||
{ | ||
public void DoSomething() | ||
{ | ||
throw new System.NotImplementedException(); | ||
} | ||
} | ||
} |
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,12 @@ | ||
namespace ModelBuilder.UnitTests.Models | ||
{ | ||
public class ParameterModel<T> | ||
{ | ||
public ParameterModel(T value) | ||
{ | ||
Value = value; | ||
} | ||
|
||
public T Value { get; } | ||
} | ||
} |
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,7 @@ | ||
namespace ModelBuilder.UnitTests.Models | ||
{ | ||
public class PropertyModel<T> where T : notnull | ||
{ | ||
public T Value { get; set; } = default!; | ||
} | ||
} |
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,74 @@ | ||
namespace ModelBuilder.UnitTests.Scenarios | ||
{ | ||
using FluentAssertions; | ||
using ModelBuilder.UnitTests.Models; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
public class TypeMappingTests | ||
{ | ||
private readonly ITestOutputHelper _output; | ||
|
||
public TypeMappingTests(ITestOutputHelper output) | ||
{ | ||
_output = output; | ||
} | ||
|
||
private interface IPrivate | ||
{ | ||
} | ||
|
||
[Fact] | ||
public void CanExplicitlyMapPrivateType() | ||
{ | ||
var strategy = Model.Mapping<IPrivate, Private>().UsingExecuteStrategy<DefaultExecuteStrategy<IPrivate>>(); | ||
|
||
var actual = strategy.Create(); | ||
|
||
_output.WriteLine(strategy.Log.Output); | ||
|
||
actual.Should().BeOfType<Private>(); | ||
} | ||
|
||
[Fact] | ||
public void CanMapParameterType() | ||
{ | ||
var strategy = Model.UsingExecuteStrategy<DefaultExecuteStrategy<ParameterModel<IItem>>>(); | ||
|
||
var actual = strategy.Create()!; | ||
|
||
_output.WriteLine(strategy.Log.Output); | ||
|
||
actual.Value.Should().BeOfType<Item>(); | ||
} | ||
|
||
[Fact] | ||
public void CanMapPropertyType() | ||
{ | ||
var strategy = Model.UsingExecuteStrategy<DefaultExecuteStrategy<PropertyModel<IItem>>>(); | ||
|
||
var actual = strategy.Create()!; | ||
|
||
_output.WriteLine(strategy.Log.Output); | ||
|
||
actual.Value.Should().BeOfType<Item>(); | ||
} | ||
|
||
[Fact] | ||
public void CanMapRootType() | ||
{ | ||
var strategy = Model.UsingExecuteStrategy<DefaultExecuteStrategy<IItem>>(); | ||
|
||
var actual = strategy.Create(); | ||
|
||
_output.WriteLine(strategy.Log.Output); | ||
|
||
actual.Should().BeOfType<Item>(); | ||
} | ||
|
||
// ReSharper disable once ClassNeverInstantiated.Local | ||
private class Private : IPrivate | ||
{ | ||
} | ||
} | ||
} |
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