0

I'm trying to write a test method for one of my controller methods. Here is the controller method

public ActionResult LicenseDetails(Guid id)
    {
        var licenseDetails = _businessUnitRepository.GetLicenseDetails(id);
        return View(licenseDetails);
    }

and here is the test i've written to check if it calls the method in repository.

 [TestMethod]
    public void ModuleDetails_Action_Calls_GetLicenseDetails()
    {
        _mockBusinessUnitRepository.GetLicenseDetails(Arg<Guid>.Is.Anything);

        _controller.LicenseDetails(Arg<Guid>.Is.Anything);

        _mockBusinessUnitRepository.AssertWasCalled(x=>x.GetLicenseDetails(Arg<Guid>.Is.Anything));
    }

I'm getting error right now that says: Test method AdminPortal.Tests.Controller_Test.Customer.BusinessUnitControllerTests.ModuleDetails_Action_Calls_GetLicenseDetails threw exception: System.InvalidOperationException: Use Arg ONLY within a mock method call while recording. 1 arguments expected, 3 have been defined.

Ps: I'm using Rhino mock and i'm new to this testing thing

4

1 回答 1

0

我认为它在抱怨这条线:

_controller.LicenseDetails(Arg<Guid>.Is.Anything);

而不是这样做,尝试传入一个实际值:

_controller.LicenseDetails(Guid.NewGuid());
于 2013-08-12T20:38:14.963 回答