locked
How to mock Date for unittests/specs and have WinRT accept the mocked Date object?

    Question

  • I am using TimeShift to mock the date in my apps specs. It seems the WinRT functions like the DateFormatter perform a strict type check on the given date object. The mocked Date object is not accepted as input.

    Windows.Globalization.DateTimeFormatting.DateTimeFormatter.format Date object expected.

    Any ideas how this could work with a mocked Date object (different library?)

    Sunday, March 15, 2015 11:16 PM

All replies

  • Hi pkursawe,

    Simply want to know by which format is your output mocked Data object, here we have a documentation for what kind of data format is acceptable in DateTimeFormatter class, see TPattern grammar and Template grammar section.

    By the way if we not sure the library can works fine together with .Net Framework, you may need consult code owner if necessary.

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 16, 2015 2:29 AM
    Moderator
  • What .Net framework you mean? I am developing a HTML/JS app. Also I think you misunderstood my problem. Its not the pattern/template grammar the problem occurs with. I am using new Windows.Globalization.DateTimeFormatting.DateTimeFormatter("shortdate shorttime")

    But calling `format` fails, cause the mocked Date object from TimeShift is not accepted by the WinRT method.

    Monday, March 16, 2015 2:33 AM