You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Whilst following this tutorial I discovered what I believe to be a breaking change.
Using the latest version of Moq (which as of this time of writing is 4.2.1408.511) the following code throws an (esoteric) exception:
[TestMethod]
public void Create()
{
var mockSet = new Mock<DbSet<Blog>>();
var mockContext = new Mock<BloggingContext>();
mockContext.Setup(m => m.Blogs).Returns(mockSet.Object);
...
The exception:
Castle.DynamicProxy.Generators.GeneratorException : Type System.Data.Entity.Internal.Linq.IInternalQueryAdapter is not visible to DynamicProxy. Can not create proxy for types that are not accessible. Make the type public, or internal and mark your assembly with [assembly: InternalsVisibleTo(InternalsVisible.ToDynamicProxyGenAssembly2)] attribute.
at Castle.DynamicProxy.DefaultProxyBuilder.AssertValidType(Type target)
at Castle.DynamicProxy.DefaultProxyBuilder.AssertValidTypes(IEnumerable1 targetTypes) at Castle.DynamicProxy.DefaultProxyBuilder.CreateClassProxyType(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options) at Castle.DynamicProxy.ProxyGenerator.CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, Object[] constructorArguments, IInterceptor[] interceptors) at Moq.Proxy.CastleProxyFactory.CreateProxy(Type mockType, ICallInterceptor interceptor, Type[] interfaces, Object[] arguments) at Moq.Mock1.b__0()
at Moq.Mock1.OnGetObject() at Moq.Mock1.get_Object()
at Blog.UnitTest.Test.Create() in Test.cs: line 19
However, using Moq 4.1.1309.1617 (which I guessed to be the version the author used based on the release date of EF6) the aforementioned code works as expected!
Please note that this occurs with both EF 6 and EF 6.1 in my experience and that I only tested that Moq 4.1.1309.1617 works - the breaking change could have been introduced after that for all I know.
The text was updated successfully, but these errors were encountered:
Whilst following this tutorial I discovered what I believe to be a breaking change.
Using the latest version of Moq (which as of this time of writing is 4.2.1408.511) the following code throws an (esoteric) exception:
The exception:
However, using Moq 4.1.1309.1617 (which I guessed to be the version the author used based on the release date of EF6) the aforementioned code works as expected!
Please note that this occurs with both EF 6 and EF 6.1 in my experience and that I only tested that Moq 4.1.1309.1617 works - the breaking change could have been introduced after that for all I know.
The text was updated successfully, but these errors were encountered: