Пример #1
0
        public void Converter_NotNullTests()
        {
            NotNull conv = new NotNull();

            Assert.AreEqual(true, conv.Convert(new object(), typeof(bool), null, CultureInfo.CurrentCulture),
                            "NotNull Convert did not return the correct value");
            Assert.AreEqual(false, conv.Convert(null, typeof(bool), null, CultureInfo.CurrentCulture),
                            "NotNull Convert did not return the correct value");
            try
            {
                conv.ConvertBack(true, typeof(object), null, CultureInfo.CurrentCulture);
                Assert.Fail("NotNull ConvertBack did not throw a NotImplemented exception");
            }
            catch (NotImplementedException) { }
        }
Пример #2
0
        public void NullCheckIsDoneCorrectly()
        {
            // Arrange
            var conv = new NotNull();

            // Act
            bool nullObject = (bool)conv.Convert(null, null, null, null);
            bool valueType  = (bool)conv.Convert(123, null, null, null);
            bool refType    = (bool)conv.Convert(string.Empty, null, null, null);

            // Assert
            Assert.IsFalse(nullObject);
            Assert.IsTrue(valueType);
            Assert.IsTrue(refType);
        }