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); }
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); }
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); }
public void CanConvertReturnsFalseForDifferentTypes() { var metadata = new ConverterMetadata { InternalSources = new[] { typeof(string), typeof(int) }, }; Assert.That(metadata.CanConvert(typeof(DateTime)), Is.False); }
public void CanConvertReturnsTrueForDerivedTypes() { var metadata = new ConverterMetadata { InternalSources = typeof(Base), }; Assert.That(metadata.CanConvert(typeof(Derived)), Is.True); }
public void CanConvertReturnsTrueForTypeInList() { var metadata = new ConverterMetadata { InternalSources = new[] { typeof(string), typeof(int) }, }; Assert.That(metadata.CanConvert(typeof(int)), Is.True); }
public void CanConvertReturnsTrueForExactType() { var metadata = new ConverterMetadata { InternalSources = typeof(int), }; Assert.That(metadata.CanConvert(typeof(int)), Is.True); }
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); }