Пример #1
0
        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 !);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }