简体   繁体   中英

MoQ - issue when trying to debug a test

Hopefully this is a simple. I just getting started with mocking frameworks and have decided to use MOQ. I'm having trouble with one of my test after setup of my mock object so i decided to step through the code. When i hit F10 after the following line:

Dim Mock = New Mock(Of IMyInterface)    <----Error When on this line and hit F10 

With Mock  
  .Setup(Function(x) x.MyProperty).Returns(5)  
  ..........

I get the following error Dialog:
"There is no source code available for the current location
[ ] Show disassembly automatically"

I originally downloaded the binaries and not the source. I thought maybe i needed to download the source and compile it in debug mode manually. Tried that but it didn't work. Tried googling around but didn't really find much.

Any help would be appreciated

Closing the post because i figured out what was going on. There was an exception in the MOQ framework and apparently visual studio was trying to break in the MOQ framework source code but could not for some reason. Not sure why since it was compiled as debug manually by me and i did include the pdb file. Anyways this line was failing:

while (stack.GetFrame(index).GetMethod().DeclaringType.Namespace.StartsWith("Moq")
            && index <= stack.FrameCount)

We usually set the base namespace on all our projects to nothing since we spell out exactly what our namespace will be. The line above doesn't like that of course and you get a "object reference not set to an instance of an object" but this isn't what i got. I will report this to the MOQ team.Still confused why i got the error i got but that is for another post :).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM