public void EnumToBooleanConverterConvertsBack()
        {
            EnumToBooleanConverter converter = new EnumToBooleanConverter();
            object value = converter.ConvertBack(true, typeof(TransactionType), TransactionType.Sell, null);

            Assert.AreEqual(TransactionType.Sell, value);
        }
        private static void TestEnumToBooleanConverterConvertBack(object value, object parameter, object expected)
        {
            _enumToBooleanConverter ??= new EnumToBooleanConverter();
            var actual = _enumToBooleanConverter.ConvertBack(value, typeof(TestEnum), parameter, CultureInfo.InvariantCulture);

            Assert.AreEqual(expected, actual);
        }
        public void EnumToBooleanConverterConvertsBackIfValueIsFalse()
        {
            EnumToBooleanConverter converter = new EnumToBooleanConverter();
            object value = converter.ConvertBack(false, typeof(TransactionType), TransactionType.Sell, null);

            Assert.IsNull(value);
        }
        public void ConvertBooleanToEnum()
        {
            var converter = new EnumToBooleanConverter();

            Assert.AreEqual(Binding.DoNothing,
                            converter.ConvertBack("test", typeof(string), "test", new CultureInfo(1)));
        }
        public void ConvertBack_InputStringRepresentation_ReturnCorrectEnumValue()
        {
            MyEnum result = (MyEnum)Converter.ConvertBack(MyEnum.val2, typeof(MyEnum), "val2", "");

            Assert.AreEqual(MyEnum.val2, result, $@"Returned enum value is diffrent from expected.
                                                    Expected: {MyEnum.val2},
                                                    Actual: {result}.");
        }
Example #6
0
        public void EnumToBooleanConverterTest()
        {
            var converter = new EnumToBooleanConverter();

            Assert.IsFalse((bool)converter.Convert(null, null, "foo", null));
            Assert.IsFalse((bool)converter.Convert(AppBarClosedDisplayMode.Compact, null, null, null));
            Assert.IsFalse((bool)converter.Convert("foo", null, "foo", null));

            Assert.IsTrue((bool)converter.Convert(AppBarClosedDisplayMode.Compact, null, "Compact", null));
            Assert.IsFalse((bool)converter.Convert(AppBarClosedDisplayMode.Compact, null, "Test", null));

            Assert.AreEqual(AppBarClosedDisplayMode.Compact, converter.ConvertBack(true, typeof(AppBarClosedDisplayMode), "Compact", null));
        }
		public void ConvertBooleanToEnum()
		{
			var converter = new EnumToBooleanConverter();
			Assert.AreEqual(Binding.DoNothing,
				converter.ConvertBack("test", typeof(string), "test", new CultureInfo(1)));
		}