Question

I have a set of tests running using MSpec. The first two run ok, but when I include the third test, the test runner crashes with a NullReferenceException before running any of the tests:

Because of = () => _result = Subject.GetReport(fooReportType);

It should_return_a_success = () => _result.Successful.ShouldBeTrue();
It should_return_something = () => _result.Data.ShouldNotBeNull();

// this test crashes
It should_return_a_concrete = _result.Data.ShouldBeOfType<IReportBase<BarChart>>;

I'm running:

  • VS 2013 RC
  • ReSharper version 8.0.2000.2660
  • Machine.Specifications 0.5.16 (according to NuGet)

I've tried replaing the type in ShouldBeOfType with ReportBase<BarChart>, the implementation of the interface as well as a concrete extension of ReportBase<BarChart>, all with the same result.

Was it helpful?

Solution

You have to be careful with ReSharper, especially when it comes to invoking the test runner. It doesn't always run the compiler and, even when it does, it can use some goofy, out-of-date shadow copies. You're gonna want to double-check your syntax...

It should_return_a_concrete = _result.Data.ShouldBeOfType<IReportBase<BarChart>>;

You're missing the delegate assignment, = () =>, and the method invocation parens at the end of the ShouldBeOfType<T>().

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top