Skip to content

Commit 8dd1be8

Browse files
committed
Add tests
1 parent 40a129f commit 8dd1be8

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

IntelliTect.TestTools.TestFramework/IntelliTect.TestTools.TestFramework.Tests/ExampleDataThing.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
namespace IntelliTect.TestTools.TestFramework.Tests
22
{
3-
public class ExampleDataThing
3+
public interface IExampleDataInterface
4+
{
5+
string Testing { get; set; }
6+
}
7+
8+
public class ExampleDataThing : IExampleDataInterface
49
{
510
public string Testing { get; set; } = "Testing";
611
}

IntelliTect.TestTools.TestFramework/IntelliTect.TestTools.TestFramework.Tests/TestBuilderTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,26 @@ public void FetchByServiceForExecuteArg()
105105
.ExecuteTestCase();
106106
}
107107

108+
[Fact]
109+
public void FetchByImplementationForExecuteArg()
110+
{
111+
TestBuilder builder = new TestBuilder();
112+
builder
113+
.AddDependencyInstance<IExampleDataInterface>(new ExampleDataThing())
114+
.AddTestBlock<ExampleTestBlockWithExecuteArgForInterface>()
115+
.ExecuteTestCase();
116+
}
117+
118+
[Fact]
119+
public void FetchByImplementationAndTypeForExecuteArg()
120+
{
121+
TestBuilder builder = new TestBuilder();
122+
builder
123+
.AddDependencyService<IExampleDataInterface, ExampleDataThing>()
124+
.AddTestBlock<ExampleTestBlockWithExecuteArgForInterface>()
125+
.ExecuteTestCase();
126+
}
127+
108128
// This test probably isn't necessary. This is MS DI out-of-the-box functionality
109129
[Fact]
110130
public void FetchByFactoryForConstructor()
@@ -375,6 +395,15 @@ public void Execute(ExampleDataThing input)
375395
}
376396
}
377397

398+
public class ExampleTestBlockWithExecuteArgForInterface : ITestBlock
399+
{
400+
public void Execute(IExampleDataInterface input)
401+
{
402+
if (input == null) throw new ArgumentNullException(nameof(input));
403+
Assert.Equal("Testing", input.Testing);
404+
}
405+
}
406+
378407
public class ExampleTestBlockWithPropertyForOwnType : ITestBlock
379408
{
380409
public ExampleDataThing Input { get; set; }

0 commit comments

Comments
 (0)