Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking Change #126

Closed
AlexArchive opened this issue Aug 6, 2014 · 3 comments
Closed

Breaking Change #126

AlexArchive opened this issue Aug 6, 2014 · 3 comments

Comments

@AlexArchive
Copy link

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.

@AlexArchive
Copy link
Author

Looks like this might have just been solved moments later here. What a stunning coincidence 😃

@kzu
Copy link
Member

kzu commented Aug 6, 2014

Yup :)

Just install the latest & greatest. Thanks! I'l pull the previous release
from nuget.org

/kzu

Daniel Cazzulino | Team Lead | Xamarin for Visual Studio

On Wed, Aug 6, 2014 at 2:20 PM, ByteBlast notifications@github.com wrote:

Looks like this might have just been solved (just moments later - what a
coincidence) here #123.

Reply to this email directly or view it on GitHub
#126 (comment).

@AlexArchive
Copy link
Author

Fix confirmed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants