public void PropertyInjectorCanSetReferenceType() { PropertyInfo property = typeof(PropertyAndFieldInvocationObject).GetProperty("Message", BindingFlags.Public | BindingFlags.Instance); IPropertyInjector injector = Factory.GetInjector(property); Assert.That(injector, Is.Not.Null); PropertyAndFieldInvocationObject mock = new PropertyAndFieldInvocationObject(); injector.Set(mock, "Hello, world!"); Assert.That(mock.Message, Is.EqualTo("Hello, world!")); }
public void PropertyInjectorCanSetValueType() { PropertyInfo property = typeof(PropertyAndFieldInvocationObject).GetProperty("Value", BindingFlags.Public | BindingFlags.Instance); IPropertyInjector injector = Factory.GetInjector(property); Assert.That(injector, Is.Not.Null); PropertyAndFieldInvocationObject mock = new PropertyAndFieldInvocationObject(); injector.Set(mock, 42); Assert.That(mock.Value, Is.EqualTo(42)); }
public void FieldInjectorCanSetValueType() { FieldInfo field = typeof(PropertyAndFieldInvocationObject).GetField("_value", BindingFlags.NonPublic | BindingFlags.Instance); IFieldInjector injector = Factory.GetInjector(field); Assert.That(injector, Is.Not.Null); PropertyAndFieldInvocationObject mock = new PropertyAndFieldInvocationObject(); injector.Set(mock, 42); Assert.That(mock.Value, Is.EqualTo(42)); }
public void FieldInjectorCanGetReferenceType() { FieldInfo field = typeof(PropertyAndFieldInvocationObject).GetField("_message", BindingFlags.NonPublic | BindingFlags.Instance); IFieldInjector injector = Factory.GetInjector(field); Assert.That(injector, Is.Not.Null); PropertyAndFieldInvocationObject mock = new PropertyAndFieldInvocationObject(); mock.Message = "Hello, world!"; string message = (string)injector.Get(mock); Assert.That(message, Is.EqualTo("Hello, world!")); }