I am attempting to setup an expectation on a repository. The method makes use of the params keyword:
string GetById(int key, params string[] args);
The expectation I have setup:
var resourceRepo = MockRepository.GenerateMock<IResourceRepository>();
resourceRepo.Expect(r => r.GetById(
    Arg<int>.Is.Equal(123),
    Arg<string>.Is.Equal("Name"),
    Arg<string>.Is.Equal("Super"),
    Arg<string>.Is.Equal("Mario"),
    Arg<string>.Is.Equal("No"),
    Arg<string>.Is.Equal("Yes"),
    Arg<string>.Is.Equal("Maybe")))
    .Return(String.Empty);
throws this exception:
Test method XYZ threw exception: System.InvalidOperationException: Use Arg ONLY within a mock method call while recording. 2 arguments expected, 7 have been defined.
What is wrong with the setup of my expectation?
params is just an array:
var resourceRepo = MockRepository.GenerateMock<IResourceRepository>();
resourceRepo
  .Expect(r => r.GetById(
    Arg<int>.Is.Equal(123),
    Arg<string[]>.List.ContainsAll(new[]
                                   {
                                       "Name",
                                       "Super",
                                       "Mario",
                                       "No",
                                       "Yes",
                                       "Maybe"
                                   })))
  .Return(String.Empty);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With