public void ConstructFieldOrPropertySetterFixture() { var action = ReflectionExtensions.ConstructFieldOrPropertySetter<ObjectWithProperties, int>("Property4"); var obj = new ObjectWithProperties(); obj.Property4 = 5; action(obj,2); obj.Property4.Should().Equal(2); }
public void ToPropertyValuesDictionaryFixture() { var testObject = new ObjectWithProperties() { NotPrimitive = new NotPrimitiveClass()}; var dictionary = testObject.ToPropertyValuesDictionary(); ((int)dictionary["Property1"]).Should().Equal(1); ((string)dictionary["Property2"]).Should().Equal("string"); ((DateTime)dictionary["Property3"]).Should().Equal(DateTime.MaxValue); ((NotPrimitiveClass)dictionary["NotPrimitive"]).Should().Not.Be.Null(); dictionary = testObject.ToPropertyValuesDictionary(filter: descriptor => descriptor.PropertyType.IsPrimitive); dictionary.Should().Count.Exactly(1); dictionary.Should().Not.Contain.One(kv => kv.Key == "NotPrimitive"); }