❔ Using Moq Library for test
I want to apply unit tests in .net framework using the Moq library. In this case, I have two projects, "Application.Test" and "Negocios". "Negocios" is referenced by "Application.Test" and contains the methods to be tested. However, when using Moq, I need to use an interface created in "Application". I cannot make a reference in "Negocios" because it would be cyclical. How can I solve this problem to perform unit tests of databases using a mock?
21 Replies
What's wrong with,
test -> nego
test -> appl
?
Anyhow, you can always break a circular dependency by adding another layer
break the problem code out of b:
i only had two projects, application.test and negocios, thers no test for application
if you only have two regular projects and a test project, then how can there be a circular ref?
application.test reference negocios project
i need to add an interfece in negocio, but i cand make the project reference, because should be a circular ref
application.tes make de interface, negocios should have the ref but application.test is referenced with negocios
You're making an interface in the test project?
no...
yes
that's why... That's wrong
moq library examples make that for mocking
make what?
moq examples uses interface in test project for mocking
then the class in tested project shoul use the interface
the interface is meant to come from your code project
Otherwise what is the point...
okay, so, the mock item should be in my project code aslo ?
nooooo
Are you sure you know what mock/moq is for?
im only telling you what i saw from moq example
It's just an example. Sounds like a bad one
or you misunderstood
can you show me a link with a propper example ?
well there will be examples on the github for it
can you show me at least one ?
https://github.com/moq/moq4
on the main page
The problem sounds like your code tbh
thanks, im going to watch mor about it
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.