Home > Blockchain >  how can i pass date time in this function for unit testing usin c#
how can i pass date time in this function for unit testing usin c#

Time:08-11

this the function i am trying to xunit test, i am new in testing. dont want to change this function

public override bool CanConvert(Type objectType)
        {
            return objectType == typeof(System.DateTime);
        }

i tried

 System.DateTime dateTime = new System.DateTime(2008, 3, 1, 7, 0, 0);

but cant pass this as argument

public void testfo()
        {
            System.DateTime dateTime = new System.DateTime(2008, 3, 1, 7, 0, 0);
CanConvert(dateTime);
        }

CodePudding user response:

Your method parameter type is Type. Just try to pass method parameter like this:

public void testfo()
{
    System.DateTime dateTime = new System.DateTime(2008, 3, 1, 7, 0, 0);
    CanConvert(dateTime.GetType());

}
  •  Tags:  
  • c#
  • Related