断言比较WCF集成测试中的类型失败

时间:2013-12-04 07:59:46

标签: wcf unit-testing mstest

我不知道为什么这个断言失败了。当我将响应变量返回并将鼠标悬停在它上面时,它似乎与typeof相同,但仍然失败。我们正在使用MSTest(不幸的是),但这里只是一些背景信息。

PreAuthorizeResponse response = serviceClient.PreAuthorize(preAuthorizeRequest);

// Assert
Assert.AreEqual(typeof(PreAuthorizeResponse), response);

1 个答案:

答案 0 :(得分:0)

您正在比较对Type的引用和对响应的引用,而不是它的类型。校正:

Assert.AreEqual(typeof(PreAuthorizeResponse), response.GetType());

您可能需要阅读question Type Checking: typeof, GetType, or is?了解更多详情。