You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.0 KiB
37 lines
1.0 KiB
// Author: Simon.Gockner
|
|
// Created: 2024-04-24
|
|
// Copyright(c) 2024 SimonG. All Rights Reserved.
|
|
|
|
using System.Reflection;
|
|
using LightweightIocContainer;
|
|
using NUnit.Framework;
|
|
|
|
namespace Test.LightweightIocContainer;
|
|
|
|
public class ExpressionsTest
|
|
{
|
|
public class TestNoCtor;
|
|
public class TestWithCtor(string name);
|
|
|
|
[Test]
|
|
public void TestCreateExpressionWithDefaultCtor()
|
|
{
|
|
Expressions expressions = new();
|
|
|
|
ConstructorInfo defaultCtor = typeof(TestNoCtor).GetConstructors().First();
|
|
TestNoCtor testNoCtor = expressions.Create<TestNoCtor>(defaultCtor);
|
|
|
|
Assert.That(testNoCtor, Is.InstanceOf<TestNoCtor>());
|
|
}
|
|
|
|
[Test]
|
|
public void TestCreateExpressionWithParamCtor()
|
|
{
|
|
Expressions expressions = new();
|
|
|
|
ConstructorInfo paramCtor = typeof(TestWithCtor).GetConstructors().First();
|
|
TestWithCtor testWithCtor = expressions.Create<TestWithCtor>(paramCtor, "TestName");
|
|
|
|
Assert.That(testWithCtor, Is.InstanceOf<TestWithCtor>());
|
|
}
|
|
} |