Implementing unit tests. Mainly for testing the Actions of gitea (#1)
All checks were successful
dotnet package / build (7.0.x) (push) Successful in 58s

Reviewed-on: #1
This commit is contained in:
Holger Börchers 2023-06-29 11:15:23 +02:00
commit 22c6f5a109
3 changed files with 18 additions and 17 deletions

View File

@ -16,4 +16,8 @@
<PackageReference Include="coverlet.collector" Version="3.1.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SmallInjector\SmallInjector.csproj" />
</ItemGroup>
</Project>

View File

@ -1,20 +1,17 @@
namespace SmallInjector.Tests
namespace SmallInjector.Tests;
public class Tests
{
public class Tests
[SetUp]
public void Setup() { }
[Test]
public void TestInstatiationAndRegistering()
{
[SetUp]
public void Setup() { }
[Test]
public void Test1()
{
Assert.Pass();
}
[Test]
public void Test2()
{
Assert.Fail();
}
IContainer container = new Container();
container.RegisterType(true, container);
Assert.That(container.IsRegistered(typeof(IContainer)), Is.True);
var resolved = container.Resolve<IContainer>();
Assert.That(resolved, Is.EqualTo(container));
}
}

View File

@ -12,7 +12,7 @@ public class Container : IContainer
{
if (!IsRegistered<TInterface>())
{
_container[typeof(TInterface)] = new List<RegisteredType> { new RegisteredType(typeof(TService), isSingleton, null) };
_container[typeof(TInterface)] = new List<RegisteredType> { new RegisteredType(typeof(TService), isSingleton, instance) };
}
else
{