public void Validation_NoReuse() { // Arrange var field = Inject.Field(nameof(DependencyInjectedType.NormalField), "test"); // Act Container.RegisterType <DependencyInjectedType>("1", field) .RegisterType <DependencyInjectedType>("2", field); }
public void Overrides_NullOverAttribute() { // Setup Container.RegisterType <ObjectWithAttributes>( Inject.Field(nameof(ObjectWithAttributes.Dependency), Name2)); // Act var result = Container.Resolve <ObjectWithAttributes>(Override.Field(nameof(ObjectWithAttributes.Dependency), null)); // Verify Assert.IsNotNull(result); Assert.IsNull(result.Dependency); Assert.IsNull(result.Optional); }
public virtual void ValueNull() { // Setup Container.RegisterType <ObjectWithThreeFields>( Inject.Field(nameof(ObjectWithThreeFields.Name), null)); // Act var result = Container.Resolve <ObjectWithThreeFields>(); // Verify Assert.IsNotNull(result); Assert.IsNull(result.Field); Assert.IsNull(result.Name); Assert.IsNotNull(result.Container); }
public void ResolverOverAttribute() { // Setup Container.RegisterType <ObjectWithAttributes>( Inject.Field(nameof(ObjectWithAttributes.Dependency), Resolve.Parameter(Name1))); // Act var result = Container.Resolve <ObjectWithAttributes>(); // Verify Assert.IsNotNull(result); Assert.IsNotNull(result.Dependency); Assert.AreEqual(result.Dependency, Name1); Assert.IsNull(result.Optional); }
public void InjectedFieldWithFieldOverride() { // Setup var noOverride = "default"; var fieldOverride = "custom-via-fieldoverride"; Container.RegisterType <TestType>(Inject.Field(nameof(TestType.DependencyField), noOverride)); // Act var defaultValue = Container.Resolve <TestType>().DependencyField; var fieldValue = Container.Resolve <TestType>(Override.Field(nameof(TestType.DependencyField), fieldOverride)) .DependencyField; // Verify Assert.AreSame(noOverride, defaultValue); Assert.AreSame(fieldOverride, fieldValue); }
public void ByNameValue() { // Setup var test = "test"; Container.RegisterType <ObjectWithThreeFields>( Inject.Field(nameof(ObjectWithThreeFields.Field), test)); // Act var result = Container.Resolve <ObjectWithThreeFields>(); // Verify Assert.IsNotNull(result); Assert.IsNotNull(result.Field); Assert.AreSame(result.Field, test); Assert.AreEqual(result.Name, Name); Assert.IsNotNull(result.Container); }
public void Validation_InjectStaticField() { // Act Container.RegisterType <DependencyInjectedType>( Inject.Field(nameof(DependencyInjectedType.StaticField), "test")); }
public void Validation_InjectProtectedField() { // Act Container.RegisterType <DependencyInjectedType>( Inject.Field("ProtectedField", "test")); }
public void InjectPrivateField() { // Act Container.RegisterType <DependencyInjectedType>( Inject.Field("PrivateField", "test")); }
public void InjectReadOnlyField() { // Act Container.RegisterType <DependencyInjectedType>( Inject.Field(nameof(DependencyInjectedType.ReadonlyField), "test")); }
public void Validation_ReadOnlyProperty() { // Act Container.RegisterType <ObjectWithFourFields>( Inject.Field(nameof(ObjectWithFourFields.ReadOnlyField), "test")); }
public void Validation_InvalidValue() { // Act Container.RegisterType <ObjectWithThreeFields>( Inject.Field(nameof(ObjectWithThreeFields.Container), Name)); }
public void InvalidValue() { // Act Container.RegisterType <Specification.Field.Injection.ObjectWithThreeFields>( Inject.Field(nameof(Specification.Field.Injection.ObjectWithThreeFields.Container), Name)); }