public void PropertyAccessors_GetPropertyValue_ValidPropertyName(string propertyName, object expectedResult)
        {
            var testObj       = new PropertyAccessorsTestClass();
            var propertyValue = testObj.GetPropertyValue(propertyName);

            Assert.Equal(propertyValue, expectedResult);
        }
        public void PropertyAccessors_GetPropertiesWithAttributes_ClassWithoutAttributes()
        {
            var testObj = new PropertyAccessorsTestClass();
            var propertyAttributesPairs = testObj.GetPropertiesWithAttribute <TestAttribute>();

            Assert.Empty(propertyAttributesPairs);
        }
        public void PropertyAccessors_SetPropertiesByValueType_NonExistingValueType()
        {
            var testObj = new PropertyAccessorsTestClass();

            testObj.SetPropertiesByValueType(true);
            Assert.Null(testObj.stringProperty1);
            Assert.Equal("abc", testObj.stringProperty2);
            Assert.Equal("def", testObj.stringProperty3);
            Assert.Equal(1, testObj.intProperty1);
            Assert.Equal(2, testObj.intProperty2);
            Assert.Equal(3, testObj.intProperty3);
        }
        public void PropertyAccessors_SetPropertiesByValueType_ReplacesExistingValueType()
        {
            var testObj = new PropertyAccessorsTestClass();

            testObj.SetPropertiesByValueType("ghi");
            Assert.Equal("ghi", testObj.stringProperty1);
            Assert.Equal("ghi", testObj.stringProperty2);
            Assert.Equal("ghi", testObj.stringProperty3);
            Assert.Equal(1, testObj.intProperty1);
            Assert.Equal(2, testObj.intProperty2);
            Assert.Equal(3, testObj.intProperty3);
        }
        public void PropertyAccessors_GetNonNullPropertiesAndValues_FindsCorrectProperties()
        {
            var testObj            = new PropertyAccessorsTestClass();
            var resultPropertyList = testObj.GetNonNullPropertiesAndValues();
            var testClassType      = typeof(PropertyAccessorsTestClass);

            Assert.Collection(resultPropertyList,
                              first => { Assert.Equal(testClassType.GetProperty("stringProperty2"), first.Property); Assert.Equal("abc", first.CorrespondingValue); },
                              second => { Assert.Equal(testClassType.GetProperty("stringProperty3"), second.Property); Assert.Equal("def", second.CorrespondingValue); },
                              third => { Assert.Equal(testClassType.GetProperty("intProperty1"), third.Property); Assert.Equal(1, third.CorrespondingValue); },
                              fourth => { Assert.Equal(testClassType.GetProperty("intProperty2"), fourth.Property); Assert.Equal(2, fourth.CorrespondingValue); },
                              fifth => { Assert.Equal(testClassType.GetProperty("intProperty3"), fifth.Property); Assert.Equal(3, fifth.CorrespondingValue); }
                              );
        }
        public void PropertyAccessors_SetPropertiesByValueType_ValueToSetIsNull()
        {
            var testObj = new PropertyAccessorsTestClass();

            Assert.Throws <ArgumentNullException>(() => PropertyAccessors.SetPropertiesByValueType(null, null));
        }
        public void PropertyAccessors_GetPropertyValue_PropertyNameIsInvalid(string propertyName)
        {
            var testObj = new PropertyAccessorsTestClass();

            Assert.Throws <ArgumentException>(() => testObj.GetPropertyValue(propertyName));
        }
        public void PropertyAccessors_GetPropertyValue_ContainingObjectIsNull()
        {
            PropertyAccessorsTestClass testObj = null;

            Assert.Throws <ArgumentNullException>(() => PropertyAccessors.GetPropertyValue(testObj, "stringProperty1"));
        }