public void It_should_format_boolean()
        {
            var attribute = new FormatBooleanAttribute("on", "off");

            Assert.That(attribute.Format(CultureInfo.InvariantCulture, true), Is.EqualTo("on"));
            Assert.That(attribute.Format(CultureInfo.InvariantCulture, false), Is.EqualTo("off"));
        }
示例#2
0
        public void CanFormat_should_accept_boolean_type()
        {
            var attribute = new FormatBooleanAttribute("yes", "no");

            Assert.That(attribute.CanFormat(typeof(bool)), Is.True);
            Assert.That(attribute.CanFormat(typeof(object)), Is.False);
        }
示例#3
0
        public void FormatValue_should_format_boolean()
        {
            var attribute = new FormatBooleanAttribute("on", "off");

            Assert.That(attribute.FormatValue(true, _formattingService), Is.EqualTo("on"));
            Assert.That(attribute.FormatValue(false, _formattingService), Is.EqualTo("off"));
        }
        public void It_should_throw_if_value_is_not_boolean()
        {
            var attribute = new FormatBooleanAttribute("on", "off");

            Assert.Throws <InvalidCastException>(() => attribute.Format(CultureInfo.InvariantCulture, 32));
        }
示例#5
0
        public void FormatValue_should_throw_if_value_is_null()
        {
            var attribute = new FormatBooleanAttribute("on", "off");

            Assert.Throws <ArgumentNullException>(() => attribute.FormatValue(null, _formattingService));
        }
示例#6
0
        public void FormatValue_should_throw_if_value_is_not_boolean()
        {
            var attribute = new FormatBooleanAttribute("on", "off");

            Assert.Throws <InvalidCastException>(() => attribute.FormatValue(32, _formattingService));
        }