【发布时间】:2016-09-24 16:17:12
【问题描述】:
我计划使用 Moq 对我的 Azure Service Fabric 应用程序进行单元测试。我在这里看到了一些例子https://github.com/Azure-Samples/service-fabric-dotnet-web-reference-app/blob/master/ReferenceApp/Inventory.UnitTests/InventoryServiceTests.cs。我看到的测试似乎实际上是在写可靠的字典而不是嘲笑。有没有办法模拟可靠字典中的添加/删除?如何对下面的内容进行单元测试
public async Task<bool> AddItem(MyItem item)
{
var items = await StateManager.GetOrAddAsync<IReliableDictionary<int, MyItem>>("itemDict");
using (ITransaction tx = this.StateManager.CreateTransaction())
{
await items.AddAsync(tx, item.Id, item);
await tx.CommitAsync();
}
return true;
}
【问题讨论】:
标签: c# unit-testing azure moq azure-service-fabric