Implementing unit tests. Mainly for testing the Actions of gitea #1

Merged
holger merged 1 commits from ImplementUnitTests into main 2023-06-29 11:15:23 +02:00
3 changed files with 18 additions and 17 deletions
Showing only changes of commit 02dbea83e7 - Show all commits

View File

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

View File

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

View File

@ -12,7 +12,7 @@ public class Container : IContainer
{ {
if (!IsRegistered<TInterface>()) 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) };
holger marked this conversation as resolved
Review

Warum muss das so?

Warum muss das so?
} }
else else
{ {