<分区> 分区>
我在我的 C# 代码中收到 IndexOutOfRangeException 的连续错误。代码片段如下:
public void GetAccountSalesDataTestWithAccountsIncluded()
{
AccountSalesDataRepository target = new AccountSalesDataRepository();
AccountSalesDataSearchCriteria[] searchCriteria = new AccountSalesDataSearchCriteria[2]
{
new AccountSalesDataSearchCriteria
{
ProgramAccountId = new AccountSalesDataSearchCriteria.SearchCriteria<int>[1] { new AccountSalesDataSearchCriteria.SearchCriteria<int>(98, true) }
},
new AccountSalesDataSearchCriteria()
};
AccountSalesDataSummary[] results;
results = target.GetAggregateAccountSalesData(searchCriteria, true);
try
{
Assert.IsNotNull(results, "The result set should not be null with the given account");
Assert.IsTrue(results.Length > 0, "The result set should not be empty with given account");
}
catch (AssertFailedException /*ex*/)
{
}
this.AccountSalesDataSummaryBasicTest(results, true);
try
{
Assert.AreEqual(results[0].AccountId, 2);
Assert.AreEqual(results[0].TotalPurchaseAmount, decimal.Parse("200"), "The total purchase amount is incorrect");
Assert.AreEqual(results[0].TotalPurchaseQuantity, 2000, "The total purchase quantity is incorrect");
Assert.AreEqual(results[0].TotalSaleQuantity, double.Parse("200"), "The total sales quantity is incorrect");
Assert.AreEqual(results[0].TotalSalesAmount, decimal.Parse("20"), "The total sales amount is incorrect");
}
catch (AssertFailedException /*ex*/)
{
}
}
这可能是什么原因?
如果我可能会说我与我的概念不一致,请原谅我,因为我对这整件事真的很陌生。
