C# 为什么我在这个MSpec测试中得到一个NullReferenceException?
所以我安装了这些nuget软件包: 在这些引用中达到高潮: 我使用NCrunch。我有这个规格:C# 为什么我在这个MSpec测试中得到一个NullReferenceException?,c#,mspec,ncrunch,C#,Mspec,Ncrunch,所以我安装了这些nuget软件包: 在这些引用中达到高潮: 我使用NCrunch。我有这个规格: namespace GlobPatternMatching.Tests { using FluentAssertions; using Machine.Fakes; using Machine.Specifications; [Subject(typeof(GlobMatching))] public class When_Given_Literal
namespace GlobPatternMatching.Tests
{
using FluentAssertions;
using Machine.Fakes;
using Machine.Specifications;
[Subject(typeof(GlobMatching))]
public class When_Given_Literal : WithSubject<GlobMatching>
{
private static string pattern = "path";
private static string[] result;
private Establish context => () =>
{
pattern = "path";
};
private Because of => () => result = Subject.GetGlobs(pattern);
private It should_return_path_in_the_array = () =>
{
result[0].Should().Be("path");
};
}
}
TDD'ing直接向上,我得到空引用异常。调试时,我无法单步执行该方法,并且所有的spec类字段都为null
我不觉得我遗漏了什么,但如果你不介意看一看,找出我做错了什么,那就好了。我正在使用最新的VS2015、NCrunch等…你不会相信问题是什么
private Establish context => () =>
{
pattern = "path";
};
private Because of => () => result = Subject.GetGlobs(pattern);
我把=>
改为=
// ----------------------\/-------
private Establish context = () =>
{
pattern = "path";
};
// ----------------\/------------
private Because of = () => result = Subject.GetGlobs(pattern);
你不会相信问题是什么
private Establish context => () =>
{
pattern = "path";
};
private Because of => () => result = Subject.GetGlobs(pattern);
我把=>
改为=
// ----------------------\/-------
private Establish context = () =>
{
pattern = "path";
};
// ----------------\/------------
private Because of = () => result = Subject.GetGlobs(pattern);