public void DefaultBooleanToBooleanConverter_ConvertBack_TargeTypeDefaultBoolean() { var converter = new DefaultBooleanToBooleanConverter(); Assert.AreEqual(DefaultBoolean.Default, converter.ConvertBack(null, typeof(DefaultBoolean), null, null)); Assert.AreEqual(DefaultBoolean.True, converter.ConvertBack(true, typeof(DefaultBoolean), null, null)); Assert.AreEqual(DefaultBoolean.False, converter.ConvertBack(false, typeof(DefaultBoolean), null, null)); Assert.AreEqual(DefaultBoolean.True, converter.ConvertBack(DefaultBoolean.True, typeof(DefaultBoolean), null, null)); Assert.AreEqual(DefaultBoolean.False, converter.ConvertBack(DefaultBoolean.False, typeof(DefaultBoolean), null, null)); Assert.AreEqual(DefaultBoolean.Default, converter.ConvertBack(DefaultBoolean.Default, typeof(DefaultBoolean), null, null)); Assert.AreEqual(DefaultBoolean.True, converter.ConvertBack(new Nullable<bool>(true), typeof(DefaultBoolean), null, null)); Assert.AreEqual(DefaultBoolean.False, converter.ConvertBack(new Nullable<bool>(false), typeof(DefaultBoolean), null, null)); Assert.AreEqual(DefaultBoolean.Default, converter.ConvertBack(new Nullable<bool>(), typeof(DefaultBoolean), null, null)); Assert.AreEqual(DefaultBoolean.Default, converter.ConvertBack("test", typeof(DefaultBoolean), null, null)); }
public void DefaultBooleanToBooleanConverter_Convert_TargetTypeNullableBool() { var converter = new DefaultBooleanToBooleanConverter(); Assert.AreEqual(null, converter.Convert(null, typeof(bool?), null, null)); Assert.AreEqual(true, converter.Convert(true, typeof(bool?), null, null)); Assert.AreEqual(false, converter.Convert(false, typeof(bool?), null, null)); Assert.AreEqual(true, converter.Convert(DefaultBoolean.True, typeof(bool?), null, null)); Assert.AreEqual(false, converter.Convert(DefaultBoolean.False, typeof(bool?), null, null)); Assert.AreEqual(null, converter.Convert(DefaultBoolean.Default, typeof(bool?), null, null)); Assert.AreEqual(true, converter.Convert(new Nullable<bool>(true), typeof(bool?), null, null)); Assert.AreEqual(false, converter.Convert(new Nullable<bool>(false), typeof(bool?), null, null)); Assert.AreEqual(null, converter.Convert(new Nullable<bool>(), typeof(bool?), null, null)); Assert.AreEqual(null, converter.Convert("test", typeof(bool?), null, null)); }