【发布时间】:2011-09-12 16:14:25
【问题描述】:
我有一个 nUnit 测试用例,它断言从 Facebook C# SDK 返回的动态。有什么方法可以使用 NUnit 流利的语法来断言它。这是我正在寻找的非常简化的示例:
// not working
var client = new FacebookClient(accessToken);
dynamic userInfo = client.Get("me");
Assert.That(userInfo, Is.Not.Null);
Assert.That(userInfo, Has.Property("id").Not.Null);
Assert.That(userInfo, Has.Property("name").Not.Null);
现在我只能通过直接指定“属性”来测试
// working, but not fluent
var client = new FacebookClient(accessToken);
dynamic userInfo = client.Get("me");
Assert.That(userInfo, Is.Not.Null);
Assert.That(userInfo.id, Is.Not.Null);
Assert.That(userInfo.name, Is.Not.Null);
感谢您的回答。
【问题讨论】:
标签: c# unit-testing dynamic nunit facebook-c#-sdk