public void UpdateNestedIntProperty() { //Arrange var person = CreatSut(); //Act PropertyReflection.SetProperty("AddressDetail.Number", person, 4); //Assert Assert.Equal(4, person.Address.Number); }
public void UpdateSingularIntProperty() { //Arrange var person = CreatSut(); //Act PropertyReflection.SetProperty("Age", person, 25); //Assert Assert.Equal(25, person.Age); }
public void UpdateNestedStringProperty() { //Arrange var person = CreatSut(); //Act PropertyReflection.SetProperty("AddressDetail.CountryDetail.CountryName", person, "SWEDEN"); //Assert Assert.Equal("SWEDEN", person.Address.Country.CountryName); }
public void ShouldSetPropertySuccessfully() { var dummyObject = new DummyObject(); var propertyReflection = new PropertyReflection(); Assert.DoesNotThrow(() => propertyReflection.SetProperty(dummyObject, "Name", "FooBar")); Assert.AreEqual(dummyObject.Name, "FooBar"); }
public void ShouldThrowExceptionWhenPropertyNotExistingOnSettingValue() { var dummyObject = new DummyObject(); var propertyReflection = new PropertyReflection(); var result = Assert.Throws<Exception>(() => propertyReflection.SetProperty(dummyObject, "Lighter", "FooBar")); Assert.IsNotNull(result); Assert.IsInstanceOf(typeof(Exception), result); Assert.AreEqual("Property Lighter does not exist on DummyObject object", result.Message); }