Timeline for Good Unit Tests when ReSharper bugs for null checks
Current License: CC BY-SA 3.0
11 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 15, 2017 at 14:56 | vote | accept | J86 | ||
Feb 1, 2017 at 12:16 | comment | added | BCdotWEB | This question might be more on-topic over at SoftwareEngineering.StackExchange.com . However, before posting please follow their tour and read "How do I ask a good question?", "What topics can I ask about here?" and "What types of questions should I avoid asking?". | |
Feb 1, 2017 at 11:40 | answer | added | t3chb0t | timeline score: 3 | |
Feb 1, 2017 at 11:35 | comment | added | 404 | Can't you just assert that it's not null, AND assert it's the expected type as well? Definitely don't make the assert conditional on it not being null, else there is no assert and it passes when null. | |
Feb 1, 2017 at 11:31 | history | edited | JanDotNet |
added tag
|
|
Feb 1, 2017 at 11:27 | answer | added | Chehre | timeline score: 1 | |
Feb 1, 2017 at 11:09 | comment | added | forsvarir |
At the moment, you're creating a variable viewModel that's only going to be populated if Model is castable to a DraftViewModel . Doing the same thing in your assert is redundant, you could just be asserting that viewModel != null . In your refactored, 'resharper friendly' approach you're going to get a pass if viewModel is null, which feels wrong. The approach I'm suggesting gets rid of the unnecessary variable and gives you a single line assert that confirms all of the expected linkages. If you don't care about them, then ignore resharper, you know the context better than it does.
|
|
Feb 1, 2017 at 11:01 | comment | added | J86 | Isn't that the same thing but written differently? | |
Feb 1, 2017 at 10:49 | comment | added | forsvarir |
Is there a reason why you don't want to do: Assert.IsInstanceOf<DraftViewModel>(viewResult?.Model); ?
|
|
Feb 1, 2017 at 10:25 | review | First posts | |||
Feb 1, 2017 at 10:49 | |||||
Feb 1, 2017 at 10:23 | history | asked | J86 | CC BY-SA 3.0 |