Skip to content

Commit

Permalink
adding bt and the rp second test
Browse files Browse the repository at this point in the history
  • Loading branch information
dadhi committed Apr 18, 2023
1 parent 3f9c009 commit 51b6117
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
19 changes: 19 additions & 0 deletions bt.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@echo off
setlocal EnableDelayedExpansion

echo:
echo:## Starting: TestRunner... ##
echo:

dotnet run -c Release --project test/DryIoc.TestRunner/DryIoc.TestRunner.csproj

if %ERRORLEVEL% neq 0 goto :error
echo:## Finished: TestRunner ##

echo:## Finished: ALL Successful ##
exit /b 0

:error
echo:
echo:## Build is failed :-(
exit /b 1
4 changes: 2 additions & 2 deletions test/DryIoc.TestRunner/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ public class Program
{
public static void Main()
{
RunAllTests();
// RunAllTests();

// new RequiredPropertiesTests().Run();
new RequiredPropertiesTests().Run();

// todo: @wip
// new GHIssue565_Is_ignoring_ReuseScoped_setting_expected_behaviour_when_also_set_to_openResolutionScope().Run();
Expand Down
14 changes: 13 additions & 1 deletion test/DryIoc.UnitTests/RequiredPropertiesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class RequiredPropertiesTests : ITest
public int Run()
{
Can_inject_required_properties();
return 1;
Should_throw_for_unresolved_required_property();
return 2;
}

[Test]
Expand All @@ -34,6 +35,17 @@ public void Can_inject_required_properties()
Assert.NotNull(x.DD);
}

[Test]
public void Should_throw_for_unresolved_required_property()
{
var c = new Container(Rules.Default.With(propertiesAndFields: PropertiesAndFields.RequiredProperties()));

c.Register<BS>();

var ex = Assert.Throws<ContainerException>(() => c.Resolve<BS>());
Assert.AreEqual(Error.NameOf(Error.UnableToResolveUnknownService), ex.ErrorName);
}

public class A {}
public class B {}
public class C {}
Expand Down

0 comments on commit 51b6117

Please sign in to comment.