예제 #1
0
        public void CanConvertSourceDestThrowsExceptionIfNullArgument()
        {
            var metadata = new ConverterMetadata {
                InternalSources      = new Type[] { typeof(int), typeof(string) },
                InternalDestinations = new Type[] { typeof(int), typeof(string) },
            };

            Assert.That(
                () => metadata.CanConvert(null, typeof(int)),
                Throws.ArgumentNullException);
            Assert.That(
                () => metadata.CanConvert(typeof(int), null),
                Throws.ArgumentNullException);
        }
예제 #2
0
        public void CanConvertReturnsForSourceAndDestInSameOrderList()
        {
            var metadata = new ConverterMetadata {
                InternalSources      = new[] { typeof(int), typeof(DateTime) },
                InternalDestinations = new[] { typeof(string), typeof(sbyte) },
            };

            Assert.That(
                metadata.CanConvert(typeof(DateTime), typeof(sbyte)),
                Is.True);
            Assert.That(
                metadata.CanConvert(typeof(DateTime), typeof(string)),
                Is.False);
        }
예제 #3
0
        public void CanConvertReturnsForExactSourceAndDest()
        {
            var metadata = new ConverterMetadata {
                InternalSources      = typeof(int),
                InternalDestinations = typeof(string),
            };

            Assert.That(
                metadata.CanConvert(typeof(int), typeof(string)),
                Is.True);
            Assert.That(
                metadata.CanConvert(typeof(string), typeof(string)),
                Is.False);
            Assert.That(
                metadata.CanConvert(typeof(int), typeof(int)),
                Is.False);
        }
예제 #4
0
        public void CanConvertReturnsFalseForDifferentTypes()
        {
            var metadata = new ConverterMetadata {
                InternalSources = new[] { typeof(string), typeof(int) },
            };

            Assert.That(metadata.CanConvert(typeof(DateTime)), Is.False);
        }
예제 #5
0
        public void CanConvertReturnsTrueForDerivedTypes()
        {
            var metadata = new ConverterMetadata {
                InternalSources = typeof(Base),
            };

            Assert.That(metadata.CanConvert(typeof(Derived)), Is.True);
        }
예제 #6
0
        public void CanConvertReturnsTrueForTypeInList()
        {
            var metadata = new ConverterMetadata {
                InternalSources = new[] { typeof(string), typeof(int) },
            };

            Assert.That(metadata.CanConvert(typeof(int)), Is.True);
        }
예제 #7
0
        public void CanConvertReturnsTrueForExactType()
        {
            var metadata = new ConverterMetadata {
                InternalSources = typeof(int),
            };

            Assert.That(metadata.CanConvert(typeof(int)), Is.True);
        }
예제 #8
0
        public void CanConvertReturnsForSourceAndDestDerived()
        {
            var metadata = new ConverterMetadata {
                InternalSources      = new[] { typeof(Base) },
                InternalDestinations = new[] { typeof(Derived) },
            };

            Assert.That(
                metadata.CanConvert(typeof(Derived), typeof(Base)),
                Is.True);

            metadata = new ConverterMetadata {
                InternalSources      = new[] { typeof(Derived) },
                InternalDestinations = new[] { typeof(Base) },
            };
            Assert.That(
                metadata.CanConvert(typeof(Base), typeof(Base)),
                Is.False);
            Assert.That(
                metadata.CanConvert(typeof(Derived), typeof(Derived)),
                Is.False);
        }