darrencauthon/AutoMoq — Issue #10: Auto-mocking an interface throws System.InvalidOperationException
Author: mrinaldi
Created: 2011-11-28 18:55:03+00:00
State: open

When I try to mock an interface like in the example below, I get the System.InvalidOperationException: The current type, [TYPE], is an interface and cannot be constructed. Are you missing a type mapping?

This is my test:

var moqer = new AutoMoqer();
var queryString = new NameValueCollection();
queryString[CultureHelper.LangParameter] = "es";
moqer.GetMock()
.SetupGet(r => r.QueryString)
.Returns(queryString);
var request = moqer.Create();
var preferencesManager = moqer.Create();
CultureHelper.InitializeCulture(request, preferencesManager);
Assert.AreEqual("es", System.Threading.Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName);

But If I write moqer.GetMock() above the Create() line, it passes.