Ejemplo n.º 1
0
        public void EnumMatchToBooleanConverter_ConvertTests()
        {
            EnumMatchToBooleanConverter converter = new EnumMatchToBooleanConverter();

            Assert.False((bool)converter.Convert(null, typeof(MyEnum), null, CultureInfo.CurrentCulture));
            Assert.True((bool)converter.Convert(MyEnum.Value12, typeof(MyEnum), "Value12", CultureInfo.CurrentCulture));
            Assert.False((bool)converter.Convert(MyEnum.Value12, typeof(MyEnum), "Value13", CultureInfo.CurrentCulture));
        }
Ejemplo n.º 2
0
        public void EnumMatchToBooleanConverter_ConvertBackTests()
        {
            EnumMatchToBooleanConverter converter = new EnumMatchToBooleanConverter();

            Assert.Null(converter.ConvertBack(null, typeof(MyEnum), null, CultureInfo.CurrentCulture));
            Assert.Equal(MyEnum.Value12, converter.ConvertBack(true, typeof(MyEnum), "Value12", CultureInfo.CurrentCulture));
            Assert.Equal(MyEnum.Value13, converter.ConvertBack(true, typeof(MyEnum), "Value13", CultureInfo.CurrentCulture));
            Assert.Equal(MyEnum.Value12, converter.ConvertBack(true, typeof(MyEnum), "12", CultureInfo.CurrentCulture));
            Assert.Equal(MyEnum.Value13, converter.ConvertBack(true, typeof(MyEnum), "13", CultureInfo.CurrentCulture));

            Assert.Null(converter.ConvertBack(false, typeof(MyEnum), "Value12", CultureInfo.CurrentCulture));
            Assert.Null(converter.ConvertBack(false, typeof(MyEnum), "Value13", CultureInfo.CurrentCulture));
            Assert.Null(converter.ConvertBack(false, typeof(MyEnum), "12", CultureInfo.CurrentCulture));
            Assert.Null(converter.ConvertBack(false, typeof(MyEnum), "13", CultureInfo.CurrentCulture));
        }