I am mocking out a wrapper we use for some enterprise library calls. All was well in the world, my tests passed and the actual code worked!
However I then extended the functionality, and verified the tests all still passed. Bingo - they did. However they didn't in the real world because there is an expectation that
InitialiseDBCommand(string, commandtype)
will be called before
AddCmdParameter(string, dbtype, object)
So like a good boy, the first thing I want to do is write a test that exhibits this behavior and expects an exception to be thrown.
What I need is to rig up AddCmmParater to throw an exception IF InitialDBCommand has not been called with any string.
I figure I could do this with a call back, but it feels like moq'ing a method call sequence (not a method return sequence) ought to be there.
Something like
iDataAccessHelper.Setup(s=>s.AddCmdOutputParameter(It.IsAny<string>(),
It.IsAny<DbType>(),
It.IsAny<int>()))
.When(w=>w.InitialiseDBCommand(etc etc)
.Throws<NullReferenceException>()
Any pointers?