Пример #1
0
        public void AssignValueToProperty_UnknownValues_ThrowsInvalidOperationException(string input)
        {
            var          attr         = new BooleanOptionAttribute("-t");
            var          container    = new Container();
            PropertyInfo propertyInfo = typeof(Container).GetProperty("DefaultFalseProperty");

            Assert.Throws <InvalidOperationException>(() => attr.AssignValueToProperty(container, propertyInfo, input));
        }
Пример #2
0
        public void AssignValueToProperty_NullValue_ThrowsArgumentNullException()
        {
            var          attr         = new BooleanOptionAttribute("-t");
            var          container    = new Container();
            PropertyInfo propertyInfo = typeof(Container).GetProperty("DefaultFalseProperty");
            string       value        = null;

            Assert.Throws <ArgumentNullException>(() => attr.AssignValueToProperty(container, propertyInfo, value));
        }
Пример #3
0
        public void AssignValueToProperty_NullPropertyInfo_ThrowsArgumentNullException()
        {
            var          attr         = new BooleanOptionAttribute("-t");
            var          container    = new Container();
            PropertyInfo propertyInfo = null;
            string       value        = "true";

            Assert.Throws <ArgumentNullException>(() => attr.AssignValueToProperty(container, propertyInfo, value));
        }
Пример #4
0
        public void AssignValueToProperty_TrueValues_AssignsTrueToProperty(string input)
        {
            var          attr         = new BooleanOptionAttribute("-t");
            var          container    = new Container();
            PropertyInfo propertyInfo = typeof(Container).GetProperty("DefaultFalseProperty");

            Assert.That(container.DefaultFalseProperty, Is.False);

            attr.AssignValueToProperty(container, propertyInfo, input);

            Assert.That(container.DefaultFalseProperty, Is.True);
            Assert.That(container.DefaultFalsePropertyWasSet, Is.True);
        }