3

Been playing around with AutoMocking.

While using moq.contrib.indy am getting the following error when calling the controller

{"Value cannot be null.\r\nParameter name: controllerContext"}

var mocks = new AutoMockContainer(new MockRepository(MockBehavior.Loose));
mocks.GetMock<IAccountService>().Setup(x => x.AddSweepstake(new AddSweepstakeViewModel()));
mocks.GetMock<IRepository<Account>>().Setup(x => x.SaveOrUpdate(new Account())).Returns(new Account()).Verifiable();

mocks.Create<AccountController>().AddSweepstake(new AddSweepstakeViewModel()); //fails on this line

Normally would do like this

var context = new Mock<HttpContextBase>();

How do I mock the controller context for this with AutoMocking?

Dr.
  • 167
  • 3
  • 11
  • I think it's very difficult to figure out what your issue is with this example--it depends on how these objects are defined. If possible, please post an entire runnable solution that demonstrates your issue. – max Dec 18 '12 at 19:43
  • Did you try container.Resolve() ? – Spock Aug 29 '13 at 11:33

0 Answers0