Adding more resolution cases
This commit is contained in:
Родитель
ee8d911681
Коммит
26925a85a0
|
@ -1,9 +1,29 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using static Unity.Specification.Property.Overrides.SpecificationTests;
|
||||
|
||||
namespace Unity.Specification.Field.Overrides
|
||||
{
|
||||
public abstract partial class SpecificationTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void CanOverrideValue()
|
||||
{
|
||||
Container.RegisterType<ObjectWithField>(Invoke.Constructor(),
|
||||
Resolve.Field(nameof(ObjectWithField.MyField)))
|
||||
.RegisterType<ISomething, Something1>()
|
||||
.RegisterType<ISomething, Something2>(Name);
|
||||
|
||||
// Act
|
||||
var result = Container.Resolve<ObjectWithField>(
|
||||
Override.Field(nameof(ObjectWithField.MyField), Resolve.Dependency<ISomething>(Name))
|
||||
.OnType<ObjectWithField>());
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(result);
|
||||
Assert.IsNotNull(result.MyField);
|
||||
Assert.IsInstanceOfType(result.MyField, typeof(Something2));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void FieldOverrideAttribute()
|
||||
{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Unity.Resolution;
|
||||
using Unity.Specification.Utility;
|
||||
|
||||
namespace Unity.Specification.Parameter.Overrides
|
||||
{
|
||||
|
|
|
@ -82,6 +82,22 @@ namespace Unity.Specification.Property.Overrides
|
|||
}
|
||||
}
|
||||
|
||||
public class ObjectWithField
|
||||
{
|
||||
public ISomething MyField;
|
||||
|
||||
public ObjectWithField()
|
||||
{
|
||||
}
|
||||
|
||||
public ObjectWithField(ISomething field)
|
||||
{
|
||||
MyField = field;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class Outer
|
||||
{
|
||||
public Outer(Inner inner, int logLevel)
|
||||
|
|
Загрузка…
Ссылка в новой задаче