Ejemplo n.º 1
0
        public void ShouldInvertBack(bool value)
        {
            var converter = new InverseBoolConverter();
            var result    = converter.ConvertBack(value, null, null, null);

            Assert.AreEqual(!value, result);
        }
Ejemplo n.º 2
0
        public void T3()
        {
            // Arrange
            var testConverter = new InverseBoolConverter();

            // Act
            var actual = testConverter.Convert(false, typeof(bool), null !, InvariantCulture);

            // Assert
            Assert.True((bool)actual);
        }
Ejemplo n.º 3
0
        public void Convert_True()
        {
            // Arrange
            var converter = new InverseBoolConverter();

            // Act
            var result = (bool)converter.Convert(true, null, null, null);

            // Assert
            Assert.IsFalse(result);
        }
Ejemplo n.º 4
0
        public void ConvertBack_NotBool()
        {
            // Arrange
            var converter = new InverseBoolConverter();

            // Act
            var result = (bool)converter.ConvertBack(new object(), null, null, null);

            // Assert
            Assert.IsFalse(result);
        }
Ejemplo n.º 5
0
        public void InverseBoolConverter_ReturnsInverseBool()
        {
            inverseBoolConverter = new InverseBoolConverter();

            bool testConvertFalse     = (bool)inverseBoolConverter.Convert(valueFalse, typeof(bool), null, CultureInfo.CurrentCulture);
            bool testConvertTrue      = (bool)inverseBoolConverter.Convert(valueTrue, typeof(bool), null, CultureInfo.CurrentCulture);
            bool testConvertBackFalse = (bool)inverseBoolConverter.ConvertBack(valueFalse, typeof(bool), null, CultureInfo.CurrentCulture);
            bool testConvertBackTrue  = (bool)inverseBoolConverter.ConvertBack(valueTrue, typeof(bool), null, CultureInfo.CurrentCulture);


            Assert.IsTrue(testConvertFalse);
            Assert.IsFalse(testConvertTrue);
            Assert.IsTrue(testConvertBackFalse);
            Assert.IsFalse(testConvertBackTrue);
        }
Ejemplo n.º 6
0
        public void InverseBoolConverter_HandlesStringInput_ExpectedInvalidCastExcpetion()
        {
            inverseBoolConverter = new InverseBoolConverter();

            valueEmptyString  = "";
            valueRandomString = "asdsadagsd";
            valueTrueString   = "true";
            valueFalseString  = "False";

            try
            {
                bool testEmptyString = (bool)inverseBoolConverter.Convert(valueEmptyString, typeof(bool), null, CultureInfo.CurrentCulture);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(typeof(InvalidCastException), ex.GetType());
            }

            try
            {
                bool testRandomString = (bool)inverseBoolConverter.Convert(valueRandomString, typeof(bool), null, CultureInfo.CurrentCulture);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(typeof(InvalidCastException), ex.GetType());
            }

            try
            {
                bool testTrueString = (bool)inverseBoolConverter.Convert(valueTrueString, typeof(bool), null, CultureInfo.CurrentCulture);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(typeof(InvalidCastException), ex.GetType());
            }

            try
            {
                bool testFalseString = (bool)inverseBoolConverter.Convert(valueFalseString, typeof(bool), null, CultureInfo.CurrentCulture);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(typeof(InvalidCastException), ex.GetType());
            }
        }
Ejemplo n.º 7
0
        public void InverseBoolConverter_HandlesNullInput_ExpectedNullReferenceExcpetion()
        {
            inverseBoolConverter = new InverseBoolConverter();
            object testConvertNull;

            try
            {
                testConvertNull = inverseBoolConverter.Convert(valueNull, typeof(bool), null, CultureInfo.CurrentCulture);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(typeof(NullReferenceException), ex.GetType());
            }

            try
            {
                testConvertNull = inverseBoolConverter.ConvertBack(valueNull, typeof(bool), null, CultureInfo.CurrentCulture);
            }
            catch (Exception ex)
            {
                Assert.AreEqual(typeof(NullReferenceException), ex.GetType());
            }
        }
Ejemplo n.º 8
0
        public void T1()
        {
            var converter = new InverseBoolConverter();

            Assert.Throws <InvalidOperationException>(() => converter.Convert(true, typeof(object), null !, InvariantCulture));
        }
Ejemplo n.º 9
0
        public void T0()
        {
            var converter = new InverseBoolConverter();

            Assert.Throws <NullReferenceException>(() => converter.Convert(null !, typeof(bool), null !, InvariantCulture));
        }
 public override object ProvideValue(IServiceProvider serviceProvider)
 {
     return(converter ?? (converter = new InverseBoolConverter()));
 }
Ejemplo n.º 11
0
        public void ShouldFailToConvertBackNonBool()
        {
            var converter = new InverseBoolConverter();

            converter.ConvertBack(new object(), null, null, null);
        }
Ejemplo n.º 12
0
 public void SetUp()
 {
     _converter = new InverseBoolConverter();
 }