Blog.Common.Utils.Tests.Helpers.PropertyReflectionTest.ShouldThrowExceptionWhenPropertyNotExistingOnGettingValue C# (CSharp) Method

ShouldThrowExceptionWhenPropertyNotExistingOnGettingValue() private method

        public void ShouldThrowExceptionWhenPropertyNotExistingOnGettingValue()
        {
            var dummyObject = new DummyObject();
            var propertyReflection = new PropertyReflection();
            var result = Assert.Throws<Exception>(() =>
                propertyReflection.GetPropertyValue(dummyObject, "Doughnut"));

            Assert.IsNotNull(result);
            Assert.IsInstanceOf(typeof(Exception), result);
            Assert.AreEqual("Property Doughnut does not exist on DummyObject object", result.Message);
        }