I am new to mocking and i just started to use moq. The tool states that we can use moq for mocking classes without interfaces
. I was wondering if it is posible when mocking to keep the internal state of the class. For example:
//define class for mocking
var mock = new Mock<ILoveThisFramework>();
//define
mock.Setup(framework => framework.DownloadExists("2.0.0.0"))
.Returns(true)
.AtMostOnce();
//use mocking tools to call methods and return defined results
The question: althought the results were defined, have the internal state (e.g. private class variables) changed? (keep the class state?)
There is no class to have state because Moq doesn't instantiate an instance of it. Instead it creates a proxy of the class (if it can) and the proxy does what you tell it to do. In your example the proxy simply returns true when the DownloadExists method is called with the appropriate argument.
--
--
Post: moq...@googlegroups.com
Unsubscribe: moqdisc-u...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "Moq Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moqdisc+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.