Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

SOLVED: Code behaves as if 1 == null when debugging (and running?) unit test

Tags: code null running

Mårten:

So I am investigating a unit test that is failing. The test fails because a function returns an "empty" value, which it only does if a certain ID is Null.

As you can see in the screenshot, my debugger says the ID is 1, which is also what I have mocked it up to be. When stepping through the Code though, it behaves as if it is null. It seems to behave as if it is null when I'm running the test normally as well.

If I do the same check in the mock setup code, the behavior is correct, it is also correct if I check it in the Test function. I wrote a test function in the class I'm testing and I'm quite certain the behavior was correct to start with, but ended up incorrect when I made some minor changes which I then reversed (code still behaving incorrectly though).

If it's relevant, we're running .net core 1.1 and entity framework core.



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
This Question have been answered
HERE


This post first appeared on Stack Solved, please read the originial post: here

Share the post

SOLVED: Code behaves as if 1 == null when debugging (and running?) unit test

×

Subscribe to Stack Solved

Get updates delivered right to your inbox!

Thank you for your subscription

×