using NUnit.Framework; using System; using System.Linq; using System.IO; using System.Collections.Generic; using IO.Swagger.Api; using IO.Swagger.Model; using IO.Swagger.Client; using System.Reflection; using Newtonsoft.Json; namespace SwaggerClientTest.TestOrder { [TestFixture ()] public class TestOrder { public TestOrder () { } /// /// Test creating a new instance of Order /// [Test ()] public void TestNewOrder() { Order o = new Order (); Assert.IsNull (o.Id); } /// /// Test deserialization of JSON to Order and its readonly property /// [Test ()] public void TesOrderDeserialization() { string json = @"{ 'id': 1982, 'petId': 1020, 'quantity': 1, 'status': 'placed', 'complete': true, }"; var o = JsonConvert.DeserializeObject(json); Assert.AreEqual (1982, o.Id); Assert.AreEqual (1020, o.PetId); Assert.AreEqual (1, o.Quantity); Assert.AreEqual (Order.StatusEnum.Placed, o.Status); Assert.AreEqual (true, o.Complete); } /// /// Test GetInvetory /// [Test ()] public void TestGetInventory () { // set timeout to 10 seconds Configuration c1 = new Configuration (timeout: 10000); StoreApi storeApi = new StoreApi (c1); Dictionary response = storeApi.GetInventory (); foreach(KeyValuePair entry in response) { Assert.IsInstanceOf (typeof(int?), entry.Value); } } /* comment out the test case as the method is not defined in original petstore spec * we will re-enable this after updating the petstore server * /// /// Test GetInvetoryInObject /// [Test ()] public void TestGetInventoryInObject () { // set timeout to 10 seconds Configuration c1 = new Configuration (timeout: 10000); StoreApi storeApi = new StoreApi (c1); Newtonsoft.Json.Linq.JObject response = (Newtonsoft.Json.Linq.JObject)storeApi.GetInventoryInObject (); // should be a Newtonsoft.Json.Linq.JObject since type is object Assert.IsInstanceOf (typeof(Newtonsoft.Json.Linq.JObject), response); foreach(KeyValuePair entry in response.ToObject>()) { Assert.IsInstanceOf (typeof(int?), Int32.Parse(entry.Value)); } }*/ } }