2016-02-23 11:16:26 +00:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
2016-03-05 08:29:25 +00:00
|
|
|
|
namespace SwaggerClientTest.TestOrder
|
2016-02-23 11:16:26 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture ()]
|
|
|
|
|
public class TestOrder
|
|
|
|
|
{
|
|
|
|
|
public TestOrder ()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Test creating a new instance of Order
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Test ()]
|
|
|
|
|
public void TestNewOrder()
|
|
|
|
|
{
|
|
|
|
|
Order o = new Order ();
|
|
|
|
|
|
|
|
|
|
Assert.IsNull (o.Id);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Test deserialization of JSON to Order and its readonly property
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Test ()]
|
|
|
|
|
public void TesOrderDeserialization()
|
|
|
|
|
{
|
|
|
|
|
string json = @"{
|
|
|
|
|
'id': 1982,
|
|
|
|
|
'petId': 1020,
|
|
|
|
|
'quantity': 1,
|
|
|
|
|
'status': 'placed',
|
|
|
|
|
'complete': true,
|
|
|
|
|
}";
|
|
|
|
|
var o = JsonConvert.DeserializeObject<Order>(json);
|
|
|
|
|
Assert.AreEqual (1982, o.Id);
|
|
|
|
|
Assert.AreEqual (1020, o.PetId);
|
|
|
|
|
Assert.AreEqual (1, o.Quantity);
|
2016-03-02 18:47:45 +00:00
|
|
|
|
Assert.AreEqual (Order.StatusEnum.Placed, o.Status);
|
2016-02-23 11:16:26 +00:00
|
|
|
|
Assert.AreEqual (true, o.Complete);
|
|
|
|
|
|
|
|
|
|
}
|
2016-03-05 08:29:25 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Test GetInvetory
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Test ()]
|
|
|
|
|
public void TestGetInventory ()
|
|
|
|
|
{
|
|
|
|
|
// set timeout to 10 seconds
|
|
|
|
|
Configuration c1 = new Configuration (timeout: 10000);
|
|
|
|
|
|
|
|
|
|
StoreApi storeApi = new StoreApi (c1);
|
|
|
|
|
Dictionary<String, int?> response = storeApi.GetInventory ();
|
|
|
|
|
|
|
|
|
|
foreach(KeyValuePair<string, int?> entry in response)
|
|
|
|
|
{
|
|
|
|
|
Assert.IsInstanceOf (typeof(int?), entry.Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-13 16:04:26 +00:00
|
|
|
|
/* 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
|
|
|
|
|
*
|
2016-03-05 08:29:25 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Test GetInvetoryInObject
|
|
|
|
|
/// </summary>
|
|
|
|
|
[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<string, string> entry in response.ToObject<Dictionary<string, string>>())
|
|
|
|
|
{
|
|
|
|
|
Assert.IsInstanceOf (typeof(int?), Int32.Parse(entry.Value));
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-13 16:04:26 +00:00
|
|
|
|
}*/
|
2016-03-05 08:29:25 +00:00
|
|
|
|
|
2016-02-23 11:16:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|