Habanero.Base.DateTimeUtcNowConverter.CanConvertTo C# (CSharp) Method

CanConvertTo() public method

Returns whether this converter can convert the object to the specified type, using the specified context.
public CanConvertTo ( ITypeDescriptorContext context, Type destinationType ) : bool
context ITypeDescriptorContext An that provides a format context. ///
destinationType System.Type A that represents the type you want to convert to. ///
return bool
        public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
        {
            if (destinationType == typeof(DateTime)) return true;
            return base.CanConvertTo(context, destinationType);
        }

Usage Example

 public void Test_CanConvertTo_WithDateTime_ShouldReturnTrue()
 {
     //---------------Set up test pack-------------------
     DateTimeUtcNowConverter dateTimeUtcNowConverter = new DateTimeUtcNowConverter();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     bool result = dateTimeUtcNowConverter.CanConvertTo(typeof(DateTime));
     //---------------Test Result -----------------------
     Assert.IsTrue(result);
 }
DateTimeUtcNowConverter