Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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());

}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading