public void MakeFastPropertySetter_SetsPropertyValues_ForNewedProperties() { // Arrange var instance = new DerivedClassWithNew(); var typeInfo = instance.GetType().GetTypeInfo(); var property = typeInfo.GetDeclaredProperty("PropB"); var propertySetter = PropertyHelper.MakeFastPropertySetter(property); // Act propertySetter(instance, "Test value"); // Assert Assert.Equal("NewedTest value", instance.PropB); }
public void PropertyHelper_ForDerivedClass_WithNew() { // Arrange var derived = new DerivedClassWithNew { PropA = "propAValue" }; // Act var helpers = PropertyHelper.GetProperties(derived).ToArray(); // Assert Assert.NotNull(helpers); Assert.Equal(2, helpers.Length); var propAHelper = Assert.Single(helpers.Where(h => h.Name == "PropA")); var propBHelper = Assert.Single(helpers.Where(h => h.Name == "PropB")); Assert.Equal("propAValue", propAHelper.GetValue(derived)); Assert.Equal("Newed", propBHelper.GetValue(derived)); }
public void PropertyHelper_ForDerivedClass_WithNew() { // Arrange var derived = new DerivedClassWithNew { PropA = "propAValue" }; // Act var helpers = PropertyHelper.GetProperties(derived).ToArray(); // Assert Assert.NotNull(helpers); Assert.Equal(2, helpers.Length); var propAHelper = Assert.Single(helpers.Where(h => h.Name == "PropA")); var propBHelper = Assert.Single(helpers.Where(h => h.Name == "PropB")); Assert.Equal("propAValue", propAHelper.GetValue(derived)); Assert.Equal("Newed", propBHelper.GetValue(derived)); }
public void MakeFastPropertySetter_SetsPropertyValues_ForNewedProperties() { // Arrange var instance = new DerivedClassWithNew(); var typeInfo = instance.GetType().GetTypeInfo(); var property = typeInfo.GetDeclaredProperty("PropB"); var propertySetter = PropertyHelper.MakeFastPropertySetter(property); // Act propertySetter(instance, "Test value"); // Assert Assert.Equal("NewedTest value", instance.PropB); }