【发布时间】:2016-10-05 12:16:19
【问题描述】:
所以我安装了这些 nuget 包:
在这些参考文献中达到高潮:
我使用 NCrunch。我有这个规格:
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");
};
}
}
对于这个类:
namespace GlobPatternMatching
{
using System;
public class GlobMatching
{
public string[] GetGlobs(string pattern)
{
return pattern.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
}
}
}
TDD 直截了当,我得到空引用异常。调试时无法单步执行该方法,并且所有规范类字段均为空.....
我不觉得我错过了什么,但如果你不介意看看我在这里做错了什么,那就太好了。我正在使用最新的 VS2015、NCrunch 等...
【问题讨论】: