Giter Club home page Giter Club logo

Comments (4)

rafaelfernandesnet avatar rafaelfernandesnet commented on September 3, 2024

​You should use Moq agains interfaces, right?

Maybe try to ​

public class ClassA : DbContext, IClassA
{
}

public class IClassA: IDbContext
{
}

[TestMethod]

public void ShouldntThrowException()
{
var mock = new Mock();
var instance = mock.Object;
}

On Tue, Dec 10, 2013 at 6:30 PM, Drew Freyling [email protected]:

Given the following nuget package:

and code:

public class ClassA : DbContext{}
[TestMethod]public void ShouldntThrowException(){
var mock = new Mock();
var instance = mock.Object;}

I'm getting an ArgumentException with "Type to mock must be an interface
or an abstract or non-sealed class.". However I don't believe this is
correct as neither ClassA or DbContext fit this criteria.

Am I missing something?


Reply to this email directly or view it on GitHubhttps://github.com//issues/67
.

from moq4.

drewfreyling avatar drewfreyling commented on September 3, 2024

Well yes that exists as a workaround but from what I can tell it should also work against a non-sealed class.

from moq4.

MikeGoldsmith avatar MikeGoldsmith commented on September 3, 2024

Doesn't look like this is an issue since going from 6.0.2-beta1 to 6.0.2. Using @drewfreyling's code sample above, the mock.object returns correctly.

Newest package versions are:

<package id="EntityFramework" version="6.0.2" targetFramework="net45" />
<package id="Moq" version="4.2.1312.1622" targetFramework="net45" />

from moq4.

bricelam avatar bricelam commented on September 3, 2024

Sorry, we (the EF team) accidentally released 6.0.2-beta1 with internals visible to DynamicProxyGenAssembly2. This was fixed in 6.0.2. (See Work Item 1907.)

from moq4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.