MsCorLib Mocking with Stopwatch

2 posts, 0 answers
  1. Tobias
    Tobias avatar
    2 posts
    Member since:
    Feb 2013

    Posted 13 May 2013 Link to this post


    I tried to do some MsCorLib Mocking following the Datetime.Now example ( and adjust it for Stopwatch.GetTimestamp().

    But somehow it does not work - What do I miss?
    Any help or hints would be great

    public class MsCorlibFixture
        static MsCorlibFixture()
            Mock.Replace(() => Stopwatch.GetTimestamp()).In<MsCorlibFixture>(x => x.ShouldAssertCustomValueForDateTime());
        public void ShouldAssertCustomValueForDateTime()
            Mock.Arrange(() => Stopwatch.GetTimestamp()).Returns(100);
            var now = Stopwatch.GetTimestamp()
            Assert.AreEqual(100, now);
  2. Kaloyan
    Kaloyan avatar
    871 posts

    Posted 14 May 2013 Link to this post

    Hi Tobias,

    Thank you for contacting Telerik support.

    At this stage, JustMock does not allow you to mock the Stopwatch class as it is being used by most of the test runners. However, we plan to release feature that will make this possible with the next JustMock version. You could expect this by the end of May 2013.

    I hope this information helps.

    Kind regards,
    the Telerik team
    Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.
  3. DevCraft R3 2016 release webinar banner
Back to Top