I have an nUnit test case that asserts the dynamic that was returned from Facebook C# SDK. Is there any way how to assert it using NUnit fluent syntax. Here is very simplified example for what I’m looking for:
// 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);
Right now I can only test by specifying ‘properties’ directly
// 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);
Thanks for your answers.
json object is IDictionary<string.object> so you can use its methods.
I haven’t used nunit fluent api but I’m guessing there might be some method like Has.Key()