Comments (2)
There are a lot of problems with this code. NSubstitute is mainly designed to mock interfaces. So it is best to hide your DbContext behind access interfaces.
You can use NSubstitute for classes, but then you must really know what you are doing. You can only mock virtual methods/properties and you cannot use any extension methods.
To make a long story short, you are much better with writing tests against the DbContext with the in memory database.
from nsubstitute.
There are a lot of problems with this code. NSubstitute is mainly designed to mock interfaces. So it is best to hide your DbContext behind access interfaces.
You can use NSubstitute for classes, but then you must really know what you are doing. You can only mock virtual methods/properties and you cannot use any extension methods.
To make a long story short, you are much better with writing tests against the DbContext with the in memory database.
I will look at just using a real db. I will create and destroy it with each test using the dbcontext. Might be slow, but should work.
from nsubstitute.
Related Issues (20)
- Need to release 5.2.0 HOT 8
- Configured calls to 'hidden' properties are not matched HOT 2
- Improve output for expected argument for custom argument matchers on non-match or make it customizable HOT 8
- Open issues that could be closed? HOT 8
- Ability to mock requests from Protected methods in sequences HOT 1
- Proposal: Replace Google groups with GitHub discussions HOT 7
- .When(...).Throws gives a CouldNotSetReturnDueToNoLastCallException HOT 1
- ReceivedCallsException despite the expected and actual calls being identical. HOT 4
- GetArguments is returning the latest call for all calls if we're using the same reference type HOT 3
- Uncommented code causes unrelated test to pass (NSubstitute version: 4.18.1) HOT 2
- Received calls method a second time. HOT 2
- Clear configured call HOT 3
- Proposal: Change Arg.Is(Expression<Predicate<T>>) to Arg.Is(Predicate<T>) HOT 1
- Precompile error during Received assertion HOT 3
- When..Do - versatile way of configuring substitutes using delegates
- Received() did not recognize call that certainly was performed correctly HOT 1
- How to tell if a method/property has been substituted/configured?
- Argument matchers fail if null passed in to an out parameter of a generic derived type
- Exception substituting internal types when targeting net8.0-android HOT 2
- NSubstitute 6.0.0 roadmap proposal HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nsubstitute.