【发布时间】:2016-10-13 17:14:33
【问题描述】:
在尝试进行一些测试驱动开发时,我创建了最基本的可构建方法:
public class NoteService : INoteService
{
public IEnumerable<Annotation> GetNotes(ODataQueryOptions oDataQueryOptions)
{
return new List<Annotation>();
}
}
在尝试对其进行单元测试时,似乎不可能创建 ODataQueryOptions 的实例:
[TestFixture]
public class NoteServiceTests
{
[Test]
public void GetNotes_Returns_IEnumerable_Of_Notes()
{
var sut = new NoteService();
var queryOptions = new ODataQueryOptions(new ODataQueryContext(new EdmCoreModel(), new EdmCollectionType())// new new new etc??
Assert.That(() => sut.GetNotes(options), Is.InstanceOf<IEnumerable<Annotation>>());
}
}
如何创建对象 ODataQueryOptions 的简单实例以便将其注入单元测试?
【问题讨论】:
-
怎么看起来不可能?
标签: c# .net unit-testing visual-studio-2015 nunit