This is a migrated thread and some comments may be shown as answers.

MsCorLib Mocking with Stopwatch

1 Answer 45 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tobias
Top achievements
Rank 1
Tobias asked on 13 May 2013, 06:49 PM
Hi,

I tried to do some MsCorLib Mocking following the Datetime.Now example (http://www.telerik.com/help/justmock/advanced-usage-mscorlib-mocking.html) and adjust it for Stopwatch.GetTimestamp().

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

Tobias

[TestClass]
public class MsCorlibFixture
{
    static MsCorlibFixture()
    {
        Mock.Replace(() => Stopwatch.GetTimestamp()).In<MsCorlibFixture>(x => x.ShouldAssertCustomValueForDateTime());
    }
 
    [TestMethod]
    public void ShouldAssertCustomValueForDateTime()
    {
        Mock.Arrange(() => Stopwatch.GetTimestamp()).Returns(100);
 
        var now = Stopwatch.GetTimestamp()
 
        Assert.AreEqual(100, now);
    }
}

1 Answer, 1 is accepted

Sort by
0
Kaloyan
Telerik team
answered on 14 May 2013, 07:03 AM
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,
Kaloyan
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.
Tags
General Discussions
Asked by
Tobias
Top achievements
Rank 1
Answers by
Kaloyan
Telerik team
Share this question
or