我计划使用Moq对我的Azure服务结构应用程序进行单元测试.我在这里看到了一些例子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;
}
Run Code Online (Sandbox Code Playgroud) 我想通过将各行的输入相乘来计算每一行的总价,然后通过使用JQuery添加Total列的所有总值来计算总计.当我输入值时,我只获得显示总计的第一行.任何帮助将不胜感激.
<script type="text/C#" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".txtMult").each(function () {
$(this).keyup(function () {
multInputs();
});
});
});
function multInputs() {
var mult = 0;
$(".txtMult").each(function () {
var $val1 = $('#val1').val();
var $val2 = $('#val2').val();
var $total = ($val1 * 1) * ($val2 * 1)
$('#multTotal').text($total);
});
}
</script>
@using (@Html.BeginForm())
{
<table>
<tr>
<th>
Quanity
</th>
<th>
Unit Price
</th>
<th>
Total
</th>
</tr>
@for (int i=0; i < 5; i++)
{
<tr>
<td>
<input class ="txtMult" …Run Code Online (Sandbox Code Playgroud)