예제 #1
0
        public void Construction_InvalidArguments_ThrowsArgumentNullException(Type nullType, Boolean?enabled)
        {
            TestClassStandard candidate = new TestClassStandard();

            PropertyInfo             property  = candidate.GetType().GetRuntimeProperty("TestType");
            ParameterObjectAttribute attribute = (ParameterObjectAttribute)property.GetCustomAttribute(typeof(OptionParameterAttribute));

            property  = nullType == typeof(PropertyInfo) ? null : property;
            attribute = nullType == typeof(ParameterObjectAttribute) ? null : attribute;

            if (enabled.HasValue)
            {
                Assert.Throws <ArgumentNullException>(() => { new ArgumentProcessorSetting(property, attribute, enabled.Value); });
            }
            else
            {
                Assert.Throws <ArgumentNullException>(() => { new ArgumentProcessorSetting(property, attribute); });
            }
        }
예제 #2
0
        public void InvokeCustomConverter_CustomConverterIsDisabled_ThrowsCustomConverterException(Boolean?enabled)
        {
            TestClassStandard candidate = new TestClassStandard();

            PropertyInfo             property  = candidate.GetType().GetRuntimeProperty("TestType");
            ParameterObjectAttribute attribute = (ParameterObjectAttribute)property.GetCustomAttribute(typeof(OptionParameterAttribute));

            ArgumentProcessorSetting actual = null;

            if (enabled.HasValue)
            {
                actual = new ArgumentProcessorSetting(property, attribute, enabled.Value);
            }
            else
            {
                actual = new ArgumentProcessorSetting(property, attribute);
            }

            Assert.That(() => actual.InvokeCustomConverter("parameter", "argument", "delimiter"), Throws.InstanceOf <CustomConverterException>());
        }
예제 #3
0
        public void Construction_TestClassOfSpecificType_CustomConverterIsDisabled(Type type)
        {
            Object candidate = null;

            if (type == typeof(TestClassStandard))
            {
                candidate = new TestClassStandard();
            }
            else if (type == typeof(TestClassNullConverter))
            {
                candidate = new TestClassNullConverter();
            }
            else if (type == typeof(TestClassConverterConstructorThrows))
            {
                candidate = new TestClassConverterConstructorThrows();
            }
            else if (type == typeof(TestClassWrongConverterWrongDataType))
            {
                candidate = new TestClassWrongConverterWrongDataType();
            }
            else if (type == typeof(TestClassWrongConverterNoGenericType))
            {
                candidate = new TestClassWrongConverterNoGenericType();
            }
            else if (type == typeof(TestClassWrongConverterWrongInterfaceType))
            {
                candidate = new TestClassWrongConverterWrongInterfaceType();
            }
            else if (type == typeof(TestClassWrongConverterNoGenericInterface))
            {
                candidate = new TestClassWrongConverterNoGenericInterface();
            }

            PropertyInfo             property  = candidate.GetType().GetRuntimeProperty("TestType");
            ParameterObjectAttribute attribute = (ParameterObjectAttribute)property.GetCustomAttribute(typeof(OptionParameterAttribute));

            ArgumentProcessorSetting actual = new ArgumentProcessorSetting(property, attribute, true);

            Assert.That(actual.CustomConverter, Is.Null);
            Assert.That(actual.HasCustomConverter, Is.False);
        }