Here is the problematic code:
var mockSet = new Mock<DbSet<Posting>>();
mockSet.As<IQueryable<Posting>>().Setup(m => m.Provider).Returns(data.Provider);
mockSet.As<IQueryable<Posting>>().Setup(m => m.Expression).Returns(data.Expression);
mockSet.As<IQueryable<Posting>>().Setup(m => m.ElementType).Returns(data.ElementType);
mockSet.As<IQueryable<Posting>>().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());
var mockContext = new Mock<CustomDbContext>();
mockContext.Setup(m => m.Postings).Returns(mockSet.Object);
It fails with a Castle proxy error:
Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type.I am following the steps to the letter Microsoft's guide to mocking in EF 6here:
http://msdn.microsoft.com/en-us/data/dn314429The custom DbContext is set up correctly with the required DbSet<> properties marked as virtual and with public get/set.
Any help is appreciated.
Will.