/// <summary> /// Checks that the property returned by reflector matches the property returned by standard reflection. /// </summary> public void GetProperty() { LightHouse.Core.Elite.Reflecting.Reflector reflector = new LightHouse.Core.Elite.Reflecting.Reflector(); PropertyInfo propertyInfo = reflector.GetProperty(typeof(Project), "Name"); PropertyInfo runtimePropertyInfo = typeof(Project).GetRuntimeProperty("Name"); Assert.True(propertyInfo.Name == runtimePropertyInfo.Name); }
/// <summary> /// Checks that the property can be retrieved correctly by it's PropertyInfo using the reflector. /// </summary> public void GetPropertyValueByPropertyInfo() { LightHouse.Core.Elite.Reflecting.Reflector reflector = new LightHouse.Core.Elite.Reflecting.Reflector(); Project project = new Project() { Name = new Localization.LocalString("LightHouse") }; PropertyInfo propertyInfo = reflector.GetProperty(typeof(Project), "Name"); LocalString name = (LocalString)reflector.GetPropertyValue(propertyInfo, project); Assert.True(name.GetContent() == "LightHouse"); propertyInfo = null; Object empty = reflector.GetPropertyValue(propertyInfo, project); Assert.True(empty == null); }
/// <summary> /// Checks that the property can be setted correctly by it's PropertyInfo using the reflector. /// </summary> public void SetPropertyValueByPropertyInfo() { LightHouse.Core.Elite.Reflecting.Reflector reflector = new LightHouse.Core.Elite.Reflecting.Reflector(); Project project = new Project(); PropertyInfo propertyInfo = reflector.GetProperty(typeof(Project), "Name"); reflector.SetPropertyValue(propertyInfo, project, new LocalString("LightHouse")); Assert.True(project.Name.GetContent() == "LightHouse"); propertyInfo = null; reflector.SetPropertyValue(propertyInfo, project, new LocalString("LightHouse")); }