【发布时间】:2010-12-17 17:51:09
【问题描述】:
我的服务设置如下:
public interface IMyService
{
void AddCountry(string countryName);
}
public class MyService : IMyService
{
public void AddCountry(string countryName)
{
/* Code here that access repository and checks if country exists or not.
If exist, throw error or just execute. */
}
}
Test.cs
[TestFixture]
public class MyServiceTest
{
[Test]
public void Country_Can_Be_Added()
{ }
[Test]
public void Duplicate_Country_Can_Not_Be_Added()
{ }
}
我如何测试 AddCountry 和 moq 存储库或服务。我真的不确定在这里做什么或模拟什么。有人可以帮帮我吗?
我正在使用的框架:
- NUnit
- 起订量
- ASP.NET MVC
【问题讨论】: