public void ConvertBack(object value, Type targetType, object parameter, object defaultValue, object result) { ValueToBooleanConverter valueConverter = new ValueToBooleanConverter { DefaultValue = defaultValue }; Assert.AreEqual(result, valueConverter.ConvertBack(value, targetType, parameter, CultureInfo.InvariantCulture)); }
public void ConvertBackShouldFail(object value, Type targetType, object parameter, object defaultValue) { ValueToBooleanConverter valueConverter = new ValueToBooleanConverter { DefaultValue = defaultValue }; Assert.AreEqual(DependencyProperty.UnsetValue, valueConverter.ConvertBack(value, targetType, parameter, CultureInfo.InvariantCulture)); }
public void DefaultValueShouldEqualValue() { ValueToBooleanConverter valueConverter = new ValueToBooleanConverter { DefaultValue = 123 }; Assert.AreEqual(123, valueConverter.DefaultValue); valueConverter.DefaultValue = "Value"; Assert.AreEqual("Value", valueConverter.DefaultValue); }
public void DefaultValueShouldEqualValue() { ValueToBooleanConverter valueConverter = new ValueToBooleanConverter { DefaultValue = 123 }; Assert.AreEqual(123, valueConverter.DefaultValue); valueConverter.DefaultValue = "Value"; Assert.AreEqual("Value", valueConverter.DefaultValue); }
public void TrueWhenEqual() { var c = new ValueToBooleanConverter(); Assert.AreEqual(true, c.Convert(true, typeof(bool), true, null)); Assert.AreEqual(false, c.Convert(false, typeof(bool), true, null)); Assert.AreEqual(false, c.Convert(true, typeof(bool), false, null)); Assert.AreEqual(true, c.Convert(false, typeof(bool), false, null)); Assert.AreEqual(false, c.Convert(null, typeof(bool), false, null)); Assert.AreEqual(false, c.Convert(true, typeof(bool), null, null)); Assert.AreEqual(true, c.Convert(null, typeof(bool), null, null)); Assert.AreEqual(false, c.Convert(null, typeof(bool), 1, null)); Assert.AreEqual(true, c.Convert(1, typeof(bool), 1, null)); Assert.AreEqual(1, c.ConvertBack(true, typeof(int), 1, null)); Assert.AreEqual(DependencyProperty.UnsetValue, c.ConvertBack(false, typeof(int), 1, null)); Assert.AreEqual(DependencyProperty.UnsetValue, c.ConvertBack(null, typeof(int), 1, null)); Assert.AreEqual(null, c.ConvertBack(true, typeof(object), null, null)); }
public void FalseWhenEqual() { var c = new ValueToBooleanConverter(false); Assert.AreEqual(false, c.Convert(true, typeof(bool), true, null)); Assert.AreEqual(true, c.Convert(false, typeof(bool), true, null)); Assert.AreEqual(true, c.Convert(true, typeof(bool), false, null)); Assert.AreEqual(false, c.Convert(false, typeof(bool), false, null)); Assert.AreEqual(true, c.Convert(null, typeof(bool), false, null)); Assert.AreEqual(true, c.Convert(true, typeof(bool), null, null)); Assert.AreEqual(false, c.Convert(null, typeof(bool), null, null)); Assert.AreEqual(true, c.Convert(null, typeof(bool), 1, null)); Assert.AreEqual(false, c.Convert(1, typeof(bool), 1, null)); Assert.AreEqual(1, c.ConvertBack(false, typeof(int), 1, null)); Assert.AreEqual(DependencyProperty.UnsetValue, c.ConvertBack(true, typeof(int), 1, null)); Assert.AreEqual(DependencyProperty.UnsetValue, c.ConvertBack(null, typeof(int), 1, null)); Assert.AreEqual(null, c.ConvertBack(false, typeof(object), null, null)); }
public void DefaultValueShouldBeNull() { ValueToBooleanConverter valueConverter = new ValueToBooleanConverter(); Assert.IsNull(valueConverter.DefaultValue); }
public void DefaultValueShouldBeNull() { ValueToBooleanConverter valueConverter = new ValueToBooleanConverter(); Assert.IsNull(valueConverter.DefaultValue); }
public void ConvertBackShouldFail(object value, Type targetType, object parameter, object defaultValue) { ValueToBooleanConverter valueConverter = new ValueToBooleanConverter { DefaultValue = defaultValue }; Assert.AreEqual(DependencyProperty.UnsetValue, valueConverter.ConvertBack(value, targetType, parameter, CultureInfo.InvariantCulture)); }
public void ConvertBack(object value, Type targetType, object parameter, object defaultValue, object result) { ValueToBooleanConverter valueConverter = new ValueToBooleanConverter { DefaultValue = defaultValue }; Assert.AreEqual(result, valueConverter.ConvertBack(value, targetType, parameter, CultureInfo.InvariantCulture)); }
public override void SetUp() { base.SetUp(); this.converter = new ValueToBooleanConverter(); }