Mocking methods with optional parameters?

2 posts, 0 answers
  1. Graham
    Graham avatar
    4 posts
    Member since:
    May 2011

    Posted 25 Apr 2012 Link to this post

    Is it possible to mock out a method with optional parameters? I can't seem to figure out how to do it.
  2. Ricky
    Ricky avatar
    467 posts

    Posted 30 Apr 2012 Link to this post

    Hi Graham,

    Thanks for bringing up the question. Yes you can mock method(s) with optional argument using JustMock. Please take a look into the following example that should give you some pointers.

           public void ShouldAssertMockingMethodWithOptionalArgument()
               var foo = Mock.Create<Foo>();
               Mock.Arrange(() => foo.Submit(true)).MustBeCalled();
           public class Foo
               public void Submit(bool visible = true)
                   // nothing

    Kind Regards
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top