コード例 #1
0
        public void ValidateUsage_OnNonBooleanProperty_ThrowsInvalidOperationException()
        {
            PropertyInfo propertyInfo = typeof(IncorrectContainer).GetProperty("DummyProperty");
            var          attr         = new BooleanOptionAttribute("-t");

            Assert.Throws <InvalidOperationException>(() => attr.ValidateUsage(propertyInfo));
        }
コード例 #2
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));
        }
コード例 #3
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));
        }
コード例 #4
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));
        }
コード例 #5
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);
        }
コード例 #6
0
        public void PropertyValue_AfterConstructorWithPropertyValue_ContainsSameValueGivenToConstructor(bool input)
        {
            var attr = new BooleanOptionAttribute("-t", input);

            Assert.That(attr.PropertyValue, Is.EqualTo(input));
        }