-
Notifications
You must be signed in to change notification settings - Fork 1
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
270b9a0
commit ba980b0
Showing
8 changed files
with
86 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Moyou.Aspects.Factory; | ||
|
||
namespace Moyou.UnitTest.Factory; | ||
|
||
[Factory] | ||
[FactoryMember(TargetType = typeof(TypeA))] | ||
[FactoryMember(TargetType = typeof(TypeB), PrimaryInterface = typeof(ITypeB))] | ||
public partial class Factory | ||
{ | ||
|
||
} |
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,26 @@ | ||
using NUnit.Framework; | ||
|
||
namespace Moyou.UnitTest.Factory; | ||
|
||
public class FactoryTest | ||
{ | ||
[Test] | ||
public void FactoryInstantiatesCorrectly() | ||
{ | ||
var sut = new Factory(); | ||
var typeA = sut.CreateTypeA(321); | ||
var typeB = sut.CreateTypeB(); | ||
|
||
Assert.Multiple(() => | ||
{ | ||
Assert.That(typeA, Is.Not.Null); | ||
Assert.That(typeB, Is.Not.Null); | ||
}); | ||
|
||
Assert.Multiple(() => | ||
{ | ||
Assert.That(typeA.Foo, Is.EqualTo(321)); | ||
Assert.That(typeB.Bar, Is.EqualTo("foobar")); | ||
}); | ||
} | ||
} |
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,6 @@ | ||
namespace Moyou.UnitTest.Factory; | ||
|
||
public interface ISomeOtherInterface | ||
{ | ||
|
||
} |
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,6 @@ | ||
namespace Moyou.UnitTest.Factory; | ||
|
||
public interface ITypeA | ||
{ | ||
int Foo { get; set; } | ||
} |
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,6 @@ | ||
namespace Moyou.UnitTest.Factory; | ||
|
||
public interface ITypeB | ||
{ | ||
string Bar { 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,19 @@ | ||
using Moyou.Aspects.Factory; | ||
|
||
namespace Moyou.UnitTest.Factory; | ||
|
||
public class TypeA : ITypeA | ||
{ | ||
public TypeA() | ||
{ | ||
Foo = 123; | ||
} | ||
|
||
[FactoryConstructor] | ||
public TypeA(int foo) | ||
{ | ||
Foo = foo; | ||
} | ||
|
||
public int Foo { get; set; } | ||
} |
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,11 @@ | ||
namespace Moyou.UnitTest.Factory; | ||
|
||
public class TypeB : ITypeB, ISomeOtherInterface | ||
{ | ||
public TypeB() | ||
{ | ||
Bar = "foobar"; | ||
} | ||
|
||
public string Bar { get; init; } | ||
} |
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