【问题标题】:Parameter count mismatch in unit test uwp project单元测试 uwp 项目中的参数计数不匹配
【发布时间】:2020-02-13 02:05:13
【问题描述】:

我有一个正在对其进行单元测试的 UWP 项目。这是代码

[UITestMethod]
[DataRow("123", IMAdSize.Banner300x50)]
public void TestValidCreationOfIMBannerObject(string placementId, IMAdSize size) {
    IMBanner banner = new IMBanner(placementId, size);
    List<IMErrorCode> receivedEvents = new List<IMErrorCode>();

    banner.OnAdFailed += delegate (object sender, IMErrorCode e) {
        receivedEvents.Add(e);
    };

     Assert.AreEqual(receivedEvents.Count, 0);
}

但是,当我运行上述测试用例时,我得到如下异常:

System.Reflection.TargetParameterCountException: Parameter count mismatch

我正在发送测试用例所需的两个参数,无法弄清楚上面的代码可能有什么问题。

【问题讨论】:

  • 可以添加异常的stacktrace吗?
  • 顺便说一句。这是次要的,但 Assert.AreEqual(receivedEvents.Count, 0); 应该是 Assert.AreEqual(0, receivedEvents.Count);
  • 我会检查 Nuget 版本号。
  • 什么样的nuget检查,@tymtam
  • 检查包含哪些版本的适配器库。

标签: c# visual-studio unit-testing uwp mstest


【解决方案1】:

我遇到了同样的问题:似乎DataRowUITestMethod 一起导致了这个错误,因为切换到TestMethod 可以消除这个错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-04
    • 2022-12-08
    • 2016-09-21
    • 1970-01-01
    • 2019-08-07
    • 2017-10-09
    • 1970-01-01
    • 2017-01-19
    相关资源
    最近更新 更多