public void DynamicObjectResultValue_DynamicCollection_Count_Should_Be_20() { //Arrange var controller = new FooController(); //Act var result = controller.GetAnonymousCollection() as JsonResult; //Assert dynamic jsonCollection = result.Value.AsDynamicObject(); Assert.AreEqual(20, jsonCollection.Count); }
public void DynamicObjectResultValue_DynamicCollection_Index_at_0_Should_Not_be_Null() { //Arrange var controller = new FooController(); //Act var result = controller.GetAnonymousCollection() as JsonResult; dynamic jsonCollection = result.Value.AsDynamicObject(); //Assert Assert.IsNotNull(jsonCollection[0]); }
public void DynamicObjectResultValue_DynamicCollection_Should_Convert_To_IEnumerable() { //Arrange var controller = new FooController(); //Act var result = controller.GetAnonymousCollection() as JsonResult; dynamic jsonCollection = result.Value.AsDynamicObject(); int count = 0; foreach (var value in jsonCollection) { count++; } //Assert Assert.IsTrue(count > 0); }
public void DynamicObjectResultValue_DynamicCollection() { //Arrange var controller = new FooController(); //Act var result = controller.GetAnonymousCollection() as JsonResult; //Assert dynamic jsonCollection = result.Value; foreach (object value in jsonCollection) { dynamic json = value.AsDynamicObject(); Assert.IsNotNull(json.id, "JSON record does not contain \"id\" required property."); Assert.IsNotNull(json.name, "JSON record does not contain \"name\" required property."); Assert.IsNotNull(json.type, "JSON record does not contain \"type\" required property."); } }
public void DynamicObjectResultValue_DynamicCollection_Should_Be_Indexable() { //Arrange var controller = new FooController(); //Act var result = controller.GetAnonymousCollection() as JsonResult; dynamic jsonCollection = result.Value.AsDynamicObject(); //Assert for (var i = 0; i < jsonCollection.Count; i++) { var json = jsonCollection[i]; Assert.IsNotNull(json); Assert.IsNotNull(json.id, "JSON record does not contain \"id\" required property."); Assert.IsNotNull(json.name, "JSON record does not contain \"name\" required property."); Assert.IsNotNull(json.type, "JSON record does not contain \"type\" required property."); } }