public void Test_Passing_Null_Object_Throws_Exception() { // ARRANGE TestThing thing = new TestThing(); Type type = thing.GetType(); PropertyInfo propertyInfo = type.GetProperties() .Single(p => p.Name == nameof(TestThing.MyPropertySomething)); // ACT _ = propertyInfo.GetValueAsString(null !); }
public void Test_Read_Null_Value_Returns_Empty_String() { // ARRANGE TestThing thing = new TestThing(); Type type = thing.GetType(); PropertyInfo propertyInfo = type.GetProperties() .Single(p => p.Name == nameof(TestThing.MyPropertyNullableLong)); // ACT string result = propertyInfo.GetValueAsString(thing); // ASSERT Assert.AreEqual(string.Empty, result); }
public void Test_Read_Object_Returns_Its_ToString() { // ARRANGE TestThing thing = new TestThing(); Type type = thing.GetType(); PropertyInfo propertyInfo = type.GetProperties() .Single(p => p.Name == nameof(TestThing.MyPropertySomething)); // ACT string result = propertyInfo.GetValueAsString(thing); // ASSERT Assert.AreEqual("My To String", result); }
public void Test_Read_Numeric_Value_As_String() { // ARRANGE TestThing thing = new TestThing(); Type type = thing.GetType(); PropertyInfo propertyInfo = type.GetProperties() .Single(p => p.Name == nameof(TestThing.MyPropertyLong)); // ACT string result = propertyInfo.GetValueAsString(thing); // ASSERT Assert.AreEqual("1", result); }