mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Merge pull request #2879 from wing328/csharp_move_test_cases
[C#] move existing test cases to auto-generated test files
This commit is contained in:
commit
d161389599
@ -32,7 +32,7 @@ namespace {{packageName}}.Test
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
instance = new {{classname}}();
|
||||
instance = new {{classname}}();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -41,7 +41,10 @@
|
||||
{{/vars}}
|
||||
public {{classname}}({{#vars}}{{^isReadOnly}}{{{datatypeWithEnum}}}{{#isEnum}}?{{/isEnum}} {{name}} = null{{/isReadOnly}}{{#hasMoreNonReadOnly}}, {{/hasMoreNonReadOnly}}{{/vars}})
|
||||
{
|
||||
{{#vars}}{{^isReadOnly}}{{#required}}// to ensure "{{name}}" is required (not null)
|
||||
{{#vars}}
|
||||
{{^isReadOnly}}
|
||||
{{#required}}
|
||||
// to ensure "{{name}}" is required (not null)
|
||||
if ({{name}} == null)
|
||||
{
|
||||
throw new InvalidDataException("{{name}} is a required property for {{classname}} and cannot be null");
|
||||
@ -50,8 +53,12 @@
|
||||
{
|
||||
this.{{name}} = {{name}};
|
||||
}
|
||||
{{/required}}{{/isReadOnly}}{{/vars}}
|
||||
{{#vars}}{{^isReadOnly}}{{^required}}
|
||||
{{/required}}
|
||||
{{/isReadOnly}}
|
||||
{{/vars}}
|
||||
{{#vars}}
|
||||
{{^isReadOnly}}
|
||||
{{^required}}
|
||||
{{#defaultValue}}// use default value if no "{{name}}" provided
|
||||
if ({{name}} == null)
|
||||
{
|
||||
@ -63,9 +70,11 @@
|
||||
}
|
||||
{{/defaultValue}}
|
||||
{{^defaultValue}}
|
||||
this.{{name}} = {{name}};
|
||||
this.{{name}} = {{name}};
|
||||
{{/defaultValue}}
|
||||
{{/required}}{{/isReadOnly}}{{/vars}}
|
||||
{{/required}}
|
||||
{{/isReadOnly}}
|
||||
{{/vars}}
|
||||
}
|
||||
|
||||
{{#vars}}
|
||||
@ -86,7 +95,8 @@
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class {{classname}} {\n");
|
||||
{{#vars}}sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
|
||||
{{#vars}}
|
||||
sb.Append(" {{name}}: ").Append({{name}}).Append("\n");
|
||||
{{/vars}}
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
|
@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
VisualStudioVersion = 12.0.0.0
|
||||
MinimumVisualStudioVersion = 10.0.0.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{74456AF8-75EE-4ABC-97EB-CA96A472DD21}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{1293D07E-F404-42B9-8BC7-0A4DAD18E83B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger.Test", "src\IO.Swagger.Test\IO.Swagger.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"
|
||||
EndProject
|
||||
@ -12,10 +12,10 @@ Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{74456AF8-75EE-4ABC-97EB-CA96A472DD21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{74456AF8-75EE-4ABC-97EB-CA96A472DD21}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{74456AF8-75EE-4ABC-97EB-CA96A472DD21}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{74456AF8-75EE-4ABC-97EB-CA96A472DD21}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1293D07E-F404-42B9-8BC7-0A4DAD18E83B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1293D07E-F404-42B9-8BC7-0A4DAD18E83B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1293D07E-F404-42B9-8BC7-0A4DAD18E83B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1293D07E-F404-42B9-8BC7-0A4DAD18E83B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
@ -6,7 +6,7 @@ This C# SDK is automatically generated by the [Swagger Codegen](https://github.c
|
||||
|
||||
- API version: 1.0.0
|
||||
- SDK version: 1.0.0
|
||||
- Build date: 2016-05-13T21:50:05.372+08:00
|
||||
- Build date: 2016-05-16T15:24:50.194+08:00
|
||||
- Build package: class io.swagger.codegen.languages.CSharpClientCodegen
|
||||
|
||||
## Frameworks supported
|
||||
|
@ -58,20 +58,22 @@ namespace IO.Swagger.Test
|
||||
[Test]
|
||||
public void TestEndpointParametersTest()
|
||||
{
|
||||
/* comment out the following as the endpiont is fake
|
||||
// TODO: add unit test for the method 'TestEndpointParameters'
|
||||
double? number = null; // TODO: replace null with proper value
|
||||
double? _double = null; // TODO: replace null with proper value
|
||||
string _string = null; // TODO: replace null with proper value
|
||||
byte[] _byte = null; // TODO: replace null with proper value
|
||||
int? integer = null; // TODO: replace null with proper value
|
||||
int? int32 = null; // TODO: replace null with proper value
|
||||
long? int64 = null; // TODO: replace null with proper value
|
||||
float? _float = null; // TODO: replace null with proper value
|
||||
double? number = 12.3; // TODO: replace null with proper value
|
||||
double? _double = 34.5; // TODO: replace null with proper value
|
||||
string _string = "charp test"; // TODO: replace null with proper value
|
||||
byte[] _byte = new byte[] { 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 };; // TODO: replace null with proper value
|
||||
int? integer = 3; // TODO: replace null with proper value
|
||||
int? int32 = 2; // TODO: replace null with proper value
|
||||
long? int64 = 1; // TODO: replace null with proper value
|
||||
float? _float = 7.8F; // TODO: replace null with proper value
|
||||
byte[] binary = null; // TODO: replace null with proper value
|
||||
DateTime? date = null; // TODO: replace null with proper value
|
||||
DateTime? date = null; // TODO: replace null with proper value
|
||||
DateTime? dateTime = null; // TODO: replace null with proper value
|
||||
string password = null; // TODO: replace null with proper value
|
||||
instance.TestEndpointParameters(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -25,13 +25,59 @@ namespace IO.Swagger.Test
|
||||
{
|
||||
private PetApi instance;
|
||||
|
||||
private long petId = 11088;
|
||||
|
||||
/// <summary>
|
||||
/// Create a Pet object
|
||||
/// </summary>
|
||||
private Pet createPet()
|
||||
{
|
||||
// create pet
|
||||
Pet p = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test" });
|
||||
p.Id = petId;
|
||||
//p.Name = "Csharp test";
|
||||
p.Status = Pet.StatusEnum.Available;
|
||||
// create Category object
|
||||
Category category = new Category();
|
||||
category.Id = 56;
|
||||
category.Name = "sample category name2";
|
||||
List<String> photoUrls = new List<String>(new String[] {"sample photoUrls"});
|
||||
// create Tag object
|
||||
Tag tag = new Tag();
|
||||
tag.Id = petId;
|
||||
tag.Name = "csharp sample tag name1";
|
||||
List<Tag> tags = new List<Tag>(new Tag[] {tag});
|
||||
p.Tags = tags;
|
||||
p.Category = category;
|
||||
p.PhotoUrls = photoUrls;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert string to byte array
|
||||
/// </summary>
|
||||
private byte[] GetBytes(string str)
|
||||
{
|
||||
byte[] bytes = new byte[str.Length * sizeof(char)];
|
||||
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Setup before each unit test
|
||||
/// </summary>
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
instance = new PetApi();
|
||||
instance = new PetApi();
|
||||
|
||||
// create pet
|
||||
Pet p = createPet();
|
||||
|
||||
// add pet before testing
|
||||
PetApi petApi = new PetApi("http://petstore.swagger.io/v2/");
|
||||
petApi.AddPet (p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -40,7 +86,9 @@ namespace IO.Swagger.Test
|
||||
[TearDown]
|
||||
public void Cleanup()
|
||||
{
|
||||
|
||||
// remove the pet after testing
|
||||
PetApi petApi = new PetApi ();
|
||||
petApi.DeletePet(petId, "test key");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -59,10 +107,10 @@ namespace IO.Swagger.Test
|
||||
[Test]
|
||||
public void AddPetTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'AddPet'
|
||||
Pet body = null; // TODO: replace null with proper value
|
||||
instance.AddPet(body);
|
||||
|
||||
// create pet
|
||||
Pet p = createPet();
|
||||
|
||||
instance.AddPet(p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -71,11 +119,7 @@ namespace IO.Swagger.Test
|
||||
[Test]
|
||||
public void DeletePetTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'DeletePet'
|
||||
long? petId = null; // TODO: replace null with proper value
|
||||
string apiKey = null; // TODO: replace null with proper value
|
||||
instance.DeletePet(petId, apiKey);
|
||||
|
||||
// no need to test as it'c covered by Cleanup() already
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -84,10 +128,15 @@ namespace IO.Swagger.Test
|
||||
[Test]
|
||||
public void FindPetsByStatusTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'FindPetsByStatus'
|
||||
List<string> status = null; // TODO: replace null with proper value
|
||||
var response = instance.FindPetsByStatus(status);
|
||||
Assert.IsInstanceOf<List<Pet>> (response, "response is List<Pet>");
|
||||
PetApi petApi = new PetApi ();
|
||||
List<String> tagsList = new List<String>(new String[] {"available"});
|
||||
|
||||
List<Pet> listPet = petApi.FindPetsByTags (tagsList);
|
||||
foreach (Pet pet in listPet) // Loop through List with foreach.
|
||||
{
|
||||
Assert.IsInstanceOf<Pet> (pet, "Response is a Pet");
|
||||
Assert.AreEqual ("csharp sample tag name1", pet.Tags[0]);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -96,8 +145,7 @@ namespace IO.Swagger.Test
|
||||
[Test]
|
||||
public void FindPetsByTagsTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'FindPetsByTags'
|
||||
List<string> tags = null; // TODO: replace null with proper value
|
||||
List<string> tags = new List<String>(new String[] {"pet"});
|
||||
var response = instance.FindPetsByTags(tags);
|
||||
Assert.IsInstanceOf<List<Pet>> (response, "response is List<Pet>");
|
||||
}
|
||||
@ -108,22 +156,96 @@ namespace IO.Swagger.Test
|
||||
[Test]
|
||||
public void GetPetByIdTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'GetPetById'
|
||||
long? petId = null; // TODO: replace null with proper value
|
||||
var response = instance.GetPetById(petId);
|
||||
Assert.IsInstanceOf<Pet> (response, "response is Pet");
|
||||
// set timeout to 10 seconds
|
||||
Configuration c1 = new Configuration (timeout: 10000, userAgent: "TEST_USER_AGENT");
|
||||
|
||||
PetApi petApi = new PetApi (c1);
|
||||
Pet response = petApi.GetPetById (petId);
|
||||
Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
|
||||
|
||||
Assert.AreEqual ("Csharp test", response.Name);
|
||||
Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
|
||||
|
||||
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
|
||||
Assert.AreEqual (petId, response.Tags [0].Id);
|
||||
Assert.AreEqual ("csharp sample tag name1", response.Tags [0].Name);
|
||||
|
||||
Assert.IsInstanceOf<List<String>> (response.PhotoUrls, "Response.PhotoUrls is a Array");
|
||||
Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
|
||||
|
||||
Assert.IsInstanceOf<Category> (response.Category, "Response.Category is a Category");
|
||||
Assert.AreEqual (56, response.Category.Id);
|
||||
Assert.AreEqual ("sample category name2", response.Category.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test GetPetByIdAsync
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestGetPetByIdAsync ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
var task = petApi.GetPetByIdAsync (petId);
|
||||
Pet response = task.Result;
|
||||
Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
|
||||
|
||||
Assert.AreEqual ("Csharp test", response.Name);
|
||||
Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
|
||||
|
||||
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
|
||||
Assert.AreEqual (petId, response.Tags [0].Id);
|
||||
Assert.AreEqual ("csharp sample tag name1", response.Tags [0].Name);
|
||||
|
||||
Assert.IsInstanceOf<List<String>> (response.PhotoUrls, "Response.PhotoUrls is a Array");
|
||||
Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
|
||||
|
||||
Assert.IsInstanceOf<Category> (response.Category, "Response.Category is a Category");
|
||||
Assert.AreEqual (56, response.Category.Id);
|
||||
Assert.AreEqual ("sample category name2", response.Category.Name);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test GetPetByIdAsyncWithHttpInfo
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestGetPetByIdAsyncWithHttpInfo ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
var task = petApi.GetPetByIdAsyncWithHttpInfo (petId);
|
||||
|
||||
Assert.AreEqual (200, task.Result.StatusCode);
|
||||
Assert.IsTrue (task.Result.Headers.ContainsKey("Content-Type"));
|
||||
Assert.AreEqual (task.Result.Headers["Content-Type"], "application/json");
|
||||
|
||||
Pet response = task.Result.Data;
|
||||
Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
|
||||
|
||||
Assert.AreEqual ("Csharp test", response.Name);
|
||||
Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
|
||||
|
||||
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
|
||||
Assert.AreEqual (petId, response.Tags [0].Id);
|
||||
Assert.AreEqual ("csharp sample tag name1", response.Tags [0].Name);
|
||||
|
||||
Assert.IsInstanceOf<List<String>> (response.PhotoUrls, "Response.PhotoUrls is a Array");
|
||||
Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
|
||||
|
||||
Assert.IsInstanceOf<Category> (response.Category, "Response.Category is a Category");
|
||||
Assert.AreEqual (56, response.Category.Id);
|
||||
Assert.AreEqual ("sample category name2", response.Category.Name);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test UpdatePet
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void UpdatePetTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'UpdatePet'
|
||||
Pet body = null; // TODO: replace null with proper value
|
||||
instance.UpdatePet(body);
|
||||
|
||||
// create pet
|
||||
Pet p = createPet();
|
||||
instance.UpdatePet(p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -132,12 +254,24 @@ namespace IO.Swagger.Test
|
||||
[Test]
|
||||
public void UpdatePetWithFormTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'UpdatePetWithForm'
|
||||
long? petId = null; // TODO: replace null with proper value
|
||||
string name = null; // TODO: replace null with proper value
|
||||
string status = null; // TODO: replace null with proper value
|
||||
instance.UpdatePetWithForm(petId, name, status);
|
||||
|
||||
PetApi petApi = new PetApi ();
|
||||
petApi.UpdatePetWithForm (petId, "new form name", "pending");
|
||||
|
||||
Pet response = petApi.GetPetById (petId);
|
||||
Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
|
||||
Assert.IsInstanceOf<Category> (response.Category, "Response.Category is a Category");
|
||||
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
|
||||
|
||||
Assert.AreEqual ("new form name", response.Name);
|
||||
Assert.AreEqual (Pet.StatusEnum.Pending, response.Status);
|
||||
|
||||
Assert.AreEqual (petId, response.Tags [0].Id);
|
||||
Assert.AreEqual (56, response.Category.Id);
|
||||
|
||||
// test optional parameter
|
||||
petApi.UpdatePetWithForm (petId, "new form name2");
|
||||
Pet response2 = petApi.GetPetById (petId);
|
||||
Assert.AreEqual ("new form name2", response2.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -146,13 +280,45 @@ namespace IO.Swagger.Test
|
||||
[Test]
|
||||
public void UploadFileTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'UploadFile'
|
||||
long? petId = null; // TODO: replace null with proper value
|
||||
string additionalMetadata = null; // TODO: replace null with proper value
|
||||
System.IO.Stream file = null; // TODO: replace null with proper value
|
||||
var response = instance.UploadFile(petId, additionalMetadata, file);
|
||||
Assert.IsInstanceOf<ApiResponse> (response, "response is ApiResponse");
|
||||
Assembly _assembly = Assembly.GetExecutingAssembly();
|
||||
Stream _imageStream = _assembly.GetManifestResourceStream("IO.Swagger.Test.swagger-logo.png");
|
||||
PetApi petApi = new PetApi ();
|
||||
// test file upload with form parameters
|
||||
petApi.UploadFile(petId, "new form name", _imageStream);
|
||||
|
||||
// test file upload without any form parameters
|
||||
// using optional parameter syntax introduced at .net 4.0
|
||||
petApi.UploadFile(petId: petId, file: _imageStream);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test status code
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestStatusCodeAndHeader ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
var response = petApi.GetPetByIdWithHttpInfo (petId);
|
||||
Assert.AreEqual (response.StatusCode, 200);
|
||||
Assert.IsTrue (response.Headers.ContainsKey("Content-Type"));
|
||||
Assert.AreEqual (response.Headers["Content-Type"], "application/json");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test default header (should be deprecated
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestDefaultHeader ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
// commented out the warning test below as it's confirmed the warning is working as expected
|
||||
// there should be a warning for using AddDefaultHeader (deprecated) below
|
||||
//petApi.AddDefaultHeader ("header_key", "header_value");
|
||||
// the following should be used instead as suggested in the doc
|
||||
petApi.Configuration.AddDefaultHeader ("header_key2", "header_value2");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using RestSharp;
|
||||
using NUnit.Framework;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using IO.Swagger.Client;
|
||||
using IO.Swagger.Api;
|
||||
@ -60,8 +61,8 @@ namespace IO.Swagger.Test
|
||||
public void DeleteOrderTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'DeleteOrder'
|
||||
string orderId = null; // TODO: replace null with proper value
|
||||
instance.DeleteOrder(orderId);
|
||||
//string orderId = null; // TODO: replace null with proper value
|
||||
//instance.DeleteOrder(orderId);
|
||||
|
||||
}
|
||||
|
||||
@ -72,8 +73,19 @@ namespace IO.Swagger.Test
|
||||
public void GetInventoryTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'GetInventory'
|
||||
var response = instance.GetInventory();
|
||||
Assert.IsInstanceOf<Dictionary<string, int?>> (response, "response is Dictionary<string, int?>");
|
||||
//var response = instance.GetInventory();
|
||||
//Assert.IsInstanceOf<Dictionary<string, int?>> (response, "response is Dictionary<string, int?>");
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -83,9 +95,9 @@ namespace IO.Swagger.Test
|
||||
public void GetOrderByIdTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'GetOrderById'
|
||||
long? orderId = null; // TODO: replace null with proper value
|
||||
var response = instance.GetOrderById(orderId);
|
||||
Assert.IsInstanceOf<Order> (response, "response is Order");
|
||||
//long? orderId = null; // TODO: replace null with proper value
|
||||
//var response = instance.GetOrderById(orderId);
|
||||
//Assert.IsInstanceOf<Order> (response, "response is Order");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -95,11 +107,41 @@ namespace IO.Swagger.Test
|
||||
public void PlaceOrderTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'PlaceOrder'
|
||||
Order body = null; // TODO: replace null with proper value
|
||||
var response = instance.PlaceOrder(body);
|
||||
Assert.IsInstanceOf<Order> (response, "response is Order");
|
||||
//Order body = null; // TODO: replace null with proper value
|
||||
//var response = instance.PlaceOrder(body);
|
||||
//Assert.IsInstanceOf<Order> (response, "response is Order");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test Enum
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestEnum ()
|
||||
{
|
||||
Assert.AreEqual (Order.StatusEnum.Approved.ToString(), "Approved");
|
||||
}
|
||||
|
||||
/// <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);
|
||||
Assert.AreEqual (Order.StatusEnum.Placed, o.Status);
|
||||
Assert.AreEqual (true, o.Complete);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -60,8 +60,8 @@ namespace IO.Swagger.Test
|
||||
public void CreateUserTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'CreateUser'
|
||||
User body = null; // TODO: replace null with proper value
|
||||
instance.CreateUser(body);
|
||||
//User body = null; // TODO: replace null with proper value
|
||||
//instance.CreateUser(body);
|
||||
|
||||
}
|
||||
|
||||
@ -72,8 +72,8 @@ namespace IO.Swagger.Test
|
||||
public void CreateUsersWithArrayInputTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'CreateUsersWithArrayInput'
|
||||
List<User> body = null; // TODO: replace null with proper value
|
||||
instance.CreateUsersWithArrayInput(body);
|
||||
//List<User> body = null; // TODO: replace null with proper value
|
||||
//instance.CreateUsersWithArrayInput(body);
|
||||
|
||||
}
|
||||
|
||||
@ -84,8 +84,8 @@ namespace IO.Swagger.Test
|
||||
public void CreateUsersWithListInputTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'CreateUsersWithListInput'
|
||||
List<User> body = null; // TODO: replace null with proper value
|
||||
instance.CreateUsersWithListInput(body);
|
||||
//List<User> body = null; // TODO: replace null with proper value
|
||||
//instance.CreateUsersWithListInput(body);
|
||||
|
||||
}
|
||||
|
||||
@ -96,8 +96,8 @@ namespace IO.Swagger.Test
|
||||
public void DeleteUserTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'DeleteUser'
|
||||
string username = null; // TODO: replace null with proper value
|
||||
instance.DeleteUser(username);
|
||||
//string username = null; // TODO: replace null with proper value
|
||||
//instance.DeleteUser(username);
|
||||
|
||||
}
|
||||
|
||||
@ -108,9 +108,9 @@ namespace IO.Swagger.Test
|
||||
public void GetUserByNameTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'GetUserByName'
|
||||
string username = null; // TODO: replace null with proper value
|
||||
var response = instance.GetUserByName(username);
|
||||
Assert.IsInstanceOf<User> (response, "response is User");
|
||||
//string username = null; // TODO: replace null with proper value
|
||||
//var response = instance.GetUserByName(username);
|
||||
//Assert.IsInstanceOf<User> (response, "response is User");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -120,10 +120,10 @@ namespace IO.Swagger.Test
|
||||
public void LoginUserTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'LoginUser'
|
||||
string username = null; // TODO: replace null with proper value
|
||||
string password = null; // TODO: replace null with proper value
|
||||
var response = instance.LoginUser(username, password);
|
||||
Assert.IsInstanceOf<string> (response, "response is string");
|
||||
//string username = null; // TODO: replace null with proper value
|
||||
//string password = null; // TODO: replace null with proper value
|
||||
//var response = instance.LoginUser(username, password);
|
||||
//Assert.IsInstanceOf<string> (response, "response is string");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -133,7 +133,7 @@ namespace IO.Swagger.Test
|
||||
public void LogoutUserTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'LogoutUser'
|
||||
instance.LogoutUser();
|
||||
//instance.LogoutUser();
|
||||
|
||||
}
|
||||
|
||||
@ -144,9 +144,9 @@ namespace IO.Swagger.Test
|
||||
public void UpdateUserTest()
|
||||
{
|
||||
// TODO: add unit test for the method 'UpdateUser'
|
||||
string username = null; // TODO: replace null with proper value
|
||||
User body = null; // TODO: replace null with proper value
|
||||
instance.UpdateUser(username, body);
|
||||
//string username = null; // TODO: replace null with proper value
|
||||
//User body = null; // TODO: replace null with proper value
|
||||
//instance.UpdateUser(username, body);
|
||||
|
||||
}
|
||||
|
||||
|
@ -3,17 +3,22 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using IO.Swagger.Client;
|
||||
using IO.Swagger.Api;
|
||||
using IO.Swagger.Model;
|
||||
|
||||
namespace SwaggerClientTest.TestApiClient
|
||||
namespace IO.Swagger.Test
|
||||
{
|
||||
public class TestApiClient
|
||||
public class ApiClientTests
|
||||
{
|
||||
[TearDown()]
|
||||
public void TearDown()
|
||||
{
|
||||
// Reset to default, just in case
|
||||
Configuration.Default.DateTimeFormat = "o";
|
||||
}
|
||||
public ApiClientTests ()
|
||||
{
|
||||
}
|
||||
|
||||
[TearDown()]
|
||||
public void TearDown()
|
||||
{
|
||||
// Reset to default, just in case
|
||||
Configuration.Default.DateTimeFormat = "o";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test SelectHeaderContentType
|
||||
@ -35,7 +40,7 @@ namespace SwaggerClientTest.TestApiClient
|
||||
/// <summary>
|
||||
/// Test ParameterToString
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
[Test ()]
|
||||
public void TestParameterToString ()
|
||||
{
|
||||
ApiClient api = new ApiClient ();
|
||||
@ -49,8 +54,8 @@ namespace SwaggerClientTest.TestApiClient
|
||||
Assert.AreEqual("1,37", api.ParameterToString (numList));
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestParameterToStringForDateTime ()
|
||||
[Test ()]
|
||||
public void TestParameterToStringForDateTime ()
|
||||
{
|
||||
ApiClient api = new ApiClient ();
|
||||
|
||||
@ -68,34 +73,34 @@ namespace SwaggerClientTest.TestApiClient
|
||||
public void TestParameterToStringWithTimeZoneForDateTime ()
|
||||
{
|
||||
ApiClient api = new ApiClient ();
|
||||
// test datetime with a time zone
|
||||
DateTimeOffset dateWithTz = DateTimeOffset.Parse("2008-04-10T13:30:00.0000000-04:00", null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||
Assert.AreEqual("2008-04-10T13:30:00.0000000-04:00", api.ParameterToString(dateWithTz));
|
||||
}
|
||||
// test datetime with a time zone
|
||||
DateTimeOffset dateWithTz = DateTimeOffset.Parse("2008-04-10T13:30:00.0000000-04:00", null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||
Assert.AreEqual("2008-04-10T13:30:00.0000000-04:00", api.ParameterToString(dateWithTz));
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestParameterToStringForDateTimeWithUFormat ()
|
||||
{
|
||||
// Setup the DateTimeFormat across all of the calls
|
||||
Configuration.Default.DateTimeFormat = "u";
|
||||
ApiClient api = new ApiClient();
|
||||
|
||||
// test datetime
|
||||
DateTime dateUtc = DateTime.Parse("2009-06-15 20:45:30Z", null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||
Assert.AreEqual("2009-06-15 20:45:30Z", api.ParameterToString(dateUtc));
|
||||
}
|
||||
[Test ()]
|
||||
public void TestParameterToStringForDateTimeWithUFormat ()
|
||||
{
|
||||
// Setup the DateTimeFormat across all of the calls
|
||||
Configuration.Default.DateTimeFormat = "u";
|
||||
ApiClient api = new ApiClient();
|
||||
|
||||
[Test ()]
|
||||
public void TestParameterToStringForDateTimeWithCustomFormat ()
|
||||
{
|
||||
// Setup the DateTimeFormat across all of the calls
|
||||
Configuration.Default.DateTimeFormat = "dd/MM/yy HH:mm:ss";
|
||||
ApiClient api = new ApiClient();
|
||||
// test datetime
|
||||
DateTime dateUtc = DateTime.Parse("2009-06-15 20:45:30Z", null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||
Assert.AreEqual("2009-06-15 20:45:30Z", api.ParameterToString(dateUtc));
|
||||
}
|
||||
|
||||
// test datetime
|
||||
DateTime dateUtc = DateTime.Parse("2009-06-15 20:45:30Z", null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||
Assert.AreEqual("15/06/09 20:45:30", api.ParameterToString(dateUtc));
|
||||
}
|
||||
[Test ()]
|
||||
public void TestParameterToStringForDateTimeWithCustomFormat ()
|
||||
{
|
||||
// Setup the DateTimeFormat across all of the calls
|
||||
Configuration.Default.DateTimeFormat = "dd/MM/yy HH:mm:ss";
|
||||
ApiClient api = new ApiClient();
|
||||
|
||||
// test datetime
|
||||
DateTime dateUtc = DateTime.Parse("2009-06-15 20:45:30Z", null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||
Assert.AreEqual("15/06/09 20:45:30", api.ParameterToString(dateUtc));
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestSanitizeFilename ()
|
||||
@ -104,7 +109,7 @@ namespace SwaggerClientTest.TestApiClient
|
||||
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("../sun.gif"));
|
||||
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("/var/tmp/sun.gif"));
|
||||
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("./sun.gif"));
|
||||
|
||||
|
||||
Assert.AreEqual("sun", ApiClient.SanitizeFilename("sun"));
|
||||
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("..\\sun.gif"));
|
||||
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("\\var\\tmp\\sun.gif"));
|
||||
@ -140,6 +145,5 @@ namespace SwaggerClientTest.TestApiClient
|
||||
Assert.AreNotSame(p4.Configuration.ApiClient, Configuration.Default.ApiClient);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -5,16 +5,20 @@ using IO.Swagger.Client;
|
||||
using IO.Swagger.Api;
|
||||
using IO.Swagger.Model;
|
||||
|
||||
namespace SwaggerClientTest.TestConfiguration
|
||||
namespace IO.Swagger.Test
|
||||
{
|
||||
public class TestConfiguration
|
||||
public class ConfigurationTests
|
||||
{
|
||||
[TearDown ()]
|
||||
public void TearDown ()
|
||||
{
|
||||
// Reset to default, just in case
|
||||
Configuration.Default.DateTimeFormat = "o";
|
||||
}
|
||||
public ConfigurationTests ()
|
||||
{
|
||||
}
|
||||
|
||||
[TearDown ()]
|
||||
public void TearDown ()
|
||||
{
|
||||
// Reset to default, just in case
|
||||
Configuration.Default.DateTimeFormat = "o";
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestAuthentication ()
|
||||
@ -39,21 +43,21 @@ namespace SwaggerClientTest.TestConfiguration
|
||||
Assert.AreNotSame (p.Configuration, Configuration.Default);
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestDateTimeFormat_Default ()
|
||||
{
|
||||
// Should default to the Round-trip Format Specifier - "o"
|
||||
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
|
||||
Assert.AreEqual("o", Configuration.Default.DateTimeFormat);
|
||||
}
|
||||
[Test ()]
|
||||
public void TestDateTimeFormat_Default ()
|
||||
{
|
||||
// Should default to the Round-trip Format Specifier - "o"
|
||||
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
|
||||
Assert.AreEqual("o", Configuration.Default.DateTimeFormat);
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestDateTimeFormat_UType()
|
||||
{
|
||||
Configuration.Default.DateTimeFormat = "u";
|
||||
[Test ()]
|
||||
public void TestDateTimeFormat_UType()
|
||||
{
|
||||
Configuration.Default.DateTimeFormat = "u";
|
||||
|
||||
Assert.AreEqual("u", Configuration.Default.DateTimeFormat);
|
||||
}
|
||||
Assert.AreEqual("u", Configuration.Default.DateTimeFormat);
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestConstructor()
|
||||
@ -64,7 +68,7 @@ namespace SwaggerClientTest.TestConfiguration
|
||||
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
[Test ()]
|
||||
public void TestDefautlConfiguration ()
|
||||
{
|
||||
PetApi p1 = new PetApi ();
|
||||
@ -110,14 +114,16 @@ namespace SwaggerClientTest.TestConfiguration
|
||||
[Test ()]
|
||||
public void TestTimeout ()
|
||||
{
|
||||
Configuration c1 = new Configuration();
|
||||
Assert.AreEqual(100000, c1.Timeout); // default vaue
|
||||
Configuration c1 = new Configuration ();
|
||||
Assert.AreEqual (100000, c1.Timeout); // default vaue
|
||||
|
||||
c1.Timeout = 50000;
|
||||
Assert.AreEqual(50000, c1.Timeout);
|
||||
Assert.AreEqual (50000, c1.Timeout);
|
||||
|
||||
Configuration c2 = new Configuration(timeout: 20000);
|
||||
Assert.AreEqual(20000, c2.Timeout);
|
||||
Configuration c2 = new Configuration (timeout: 20000);
|
||||
Assert.AreEqual (20000, c2.Timeout);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@ -38,36 +38,43 @@
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs"/>
|
||||
<Compile Include="**\*.cs" />
|
||||
<Compile Include="Client\ApiClientTests.cs" />
|
||||
<Compile Include="Client\ConfigurationTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\IO.Swagger\IO.Swagger.csproj">
|
||||
<Project>{74456AF8-75EE-4ABC-97EB-CA96A472DD21}</Project>
|
||||
<Name>IO.Swagger</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\IO.Swagger\IO.Swagger.csproj">
|
||||
<Project>{1293D07E-F404-42B9-8BC7-0A4DAD18E83B}</Project>
|
||||
<Name>IO.Swagger</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="swagger-logo.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Client\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace IO.Swagger.Test
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
instance = new Animal();
|
||||
instance = new Animal(ClassName: "csharp test");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -29,7 +29,7 @@ namespace IO.Swagger.Test
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
instance = new Cat();
|
||||
instance = new Cat(ClassName: "csharp test");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -29,7 +29,7 @@ namespace IO.Swagger.Test
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
instance = new Dog();
|
||||
instance = new Dog(ClassName: "csharp test");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -50,6 +50,22 @@ namespace IO.Swagger.Test
|
||||
Assert.IsInstanceOf<EnumClass> (instance, "instance is a EnumClass");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test EnumClass
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void EnumClassValueTest ()
|
||||
{
|
||||
// test serialization for string
|
||||
Assert.AreEqual (Newtonsoft.Json.JsonConvert.SerializeObject(EnumClass.Abc), "\"_abc\"");
|
||||
|
||||
// test serialization for number
|
||||
Assert.AreEqual (Newtonsoft.Json.JsonConvert.SerializeObject(EnumTest.EnumIntegerEnum.NUMBER_MINUS_1), "\"-1\"");
|
||||
|
||||
// test cast to int
|
||||
Assert.AreEqual ((int)EnumTest.EnumIntegerEnum.NUMBER_MINUS_1, -1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace IO.Swagger.Test
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
instance = new FormatTest();
|
||||
instance = new FormatTest(Number: 123, _Byte: new byte[] { 0x20 }, Date: new DateTime(2015, 1, 18), Password: "xyz");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -29,7 +29,7 @@ namespace IO.Swagger.Test
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
instance = new Name();
|
||||
instance = new Name(_Name: 1, Property: "csharp");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -41,6 +41,16 @@ namespace IO.Swagger.Test
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test creating a new instance of Order
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestNewOrder()
|
||||
{
|
||||
Order o = new Order ();
|
||||
Assert.IsNull (o.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test an instance of Order
|
||||
/// </summary>
|
||||
|
@ -23,13 +23,15 @@ namespace IO.Swagger.Test
|
||||
{
|
||||
private Pet instance;
|
||||
|
||||
private long petId = 11088;
|
||||
|
||||
/// <summary>
|
||||
/// Setup before each test
|
||||
/// </summary>
|
||||
[SetUp]
|
||||
public void Init()
|
||||
{
|
||||
instance = new Pet();
|
||||
instance = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test" });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -99,6 +101,69 @@ namespace IO.Swagger.Test
|
||||
// TODO: unit test for the property 'Status'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test Equal
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestEqual()
|
||||
{
|
||||
// create pet
|
||||
Pet p1 = new Pet (Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test" });
|
||||
p1.Id = petId;
|
||||
//p1.Name = "Csharp test";
|
||||
p1.Status = Pet.StatusEnum.Available;
|
||||
// create Category object
|
||||
Category category1 = new Category ();
|
||||
category1.Id = 56;
|
||||
category1.Name = "sample category name2";
|
||||
List<String> photoUrls1 = new List<String> (new String[] { "sample photoUrls" });
|
||||
// create Tag object
|
||||
Tag tag1 = new Tag ();
|
||||
tag1.Id = petId;
|
||||
tag1.Name = "csharp sample tag name1";
|
||||
List<Tag> tags1 = new List<Tag> (new Tag[] { tag1 });
|
||||
p1.Tags = tags1;
|
||||
p1.Category = category1;
|
||||
p1.PhotoUrls = photoUrls1;
|
||||
|
||||
// create pet 2
|
||||
Pet p2 = new Pet (Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test" });
|
||||
p2.Id = petId;
|
||||
p2.Name = "Csharp test";
|
||||
p2.Status = Pet.StatusEnum.Available;
|
||||
// create Category object
|
||||
Category category2 = new Category ();
|
||||
category2.Id = 56;
|
||||
category2.Name = "sample category name2";
|
||||
List<String> photoUrls2 = new List<String> (new String[] { "sample photoUrls" });
|
||||
// create Tag object
|
||||
Tag tag2 = new Tag ();
|
||||
tag2.Id = petId;
|
||||
tag2.Name = "csharp sample tag name1";
|
||||
List<Tag> tags2 = new List<Tag> (new Tag[] { tag2 });
|
||||
p2.Tags = tags2;
|
||||
p2.Category = category2;
|
||||
p2.PhotoUrls = photoUrls2;
|
||||
|
||||
// p1 and p2 should be equal (both object and attribute level)
|
||||
Assert.IsTrue (category1.Equals (category2));
|
||||
Assert.IsTrue (tags1.SequenceEqual (tags2));
|
||||
Assert.IsTrue (p1.PhotoUrls.SequenceEqual (p2.PhotoUrls));
|
||||
|
||||
Assert.IsTrue (p1.Equals (p2));
|
||||
|
||||
// update attribute to that p1 and p2 are not equal
|
||||
category2.Name = "new category name";
|
||||
Assert.IsFalse (category1.Equals (category2));
|
||||
|
||||
tags2 = new List<Tag> ();
|
||||
Assert.IsFalse (tags1.SequenceEqual (tags2));
|
||||
|
||||
// photoUrls has not changed so it should be equal
|
||||
Assert.IsTrue (p1.PhotoUrls.SequenceEqual (p2.PhotoUrls));
|
||||
|
||||
Assert.IsFalse (p1.Equals (p2));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{74456AF8-75EE-4ABC-97EB-CA96A472DD21}</ProjectGuid>
|
||||
<ProjectGuid>{1293D07E-F404-42B9-8BC7-0A4DAD18E83B}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Swagger Library</RootNamespace>
|
||||
|
@ -38,8 +38,6 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
this.ClassName = ClassName;
|
||||
}
|
||||
|
||||
|
||||
// use default value if no "Color" provided
|
||||
if (Color == null)
|
||||
{
|
||||
@ -49,7 +47,6 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
this.Color = Color;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -71,7 +68,7 @@ namespace IO.Swagger.Model
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Animal {\n");
|
||||
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
|
||||
sb.Append(" Color: ").Append(Color).Append("\n");
|
||||
sb.Append(" Color: ").Append(Color).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -22,8 +22,6 @@ namespace IO.Swagger.Model
|
||||
/// </summary>
|
||||
public AnimalFarm()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -34,7 +32,7 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class AnimalFarm {\n");
|
||||
sb.Append("}\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
@ -25,14 +25,9 @@ namespace IO.Swagger.Model
|
||||
/// <param name="Message">Message.</param>
|
||||
public ApiResponse(int? Code = null, string Type = null, string Message = null)
|
||||
{
|
||||
|
||||
|
||||
this.Code = Code;
|
||||
|
||||
this.Type = Type;
|
||||
|
||||
this.Message = Message;
|
||||
|
||||
this.Code = Code;
|
||||
this.Type = Type;
|
||||
this.Message = Message;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -59,8 +54,8 @@ namespace IO.Swagger.Model
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class ApiResponse {\n");
|
||||
sb.Append(" Code: ").Append(Code).Append("\n");
|
||||
sb.Append(" Type: ").Append(Type).Append("\n");
|
||||
sb.Append(" Message: ").Append(Message).Append("\n");
|
||||
sb.Append(" Type: ").Append(Type).Append("\n");
|
||||
sb.Append(" Message: ").Append(Message).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -39,8 +39,6 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
this.ClassName = ClassName;
|
||||
}
|
||||
|
||||
|
||||
// use default value if no "Color" provided
|
||||
if (Color == null)
|
||||
{
|
||||
@ -50,9 +48,7 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
this.Color = Color;
|
||||
}
|
||||
|
||||
this.Declawed = Declawed;
|
||||
|
||||
this.Declawed = Declawed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -79,8 +75,8 @@ namespace IO.Swagger.Model
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Cat {\n");
|
||||
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
|
||||
sb.Append(" Color: ").Append(Color).Append("\n");
|
||||
sb.Append(" Declawed: ").Append(Declawed).Append("\n");
|
||||
sb.Append(" Color: ").Append(Color).Append("\n");
|
||||
sb.Append(" Declawed: ").Append(Declawed).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -24,12 +24,8 @@ namespace IO.Swagger.Model
|
||||
/// <param name="Name">Name.</param>
|
||||
public Category(long? Id = null, string Name = null)
|
||||
{
|
||||
|
||||
|
||||
this.Id = Id;
|
||||
|
||||
this.Name = Name;
|
||||
|
||||
this.Id = Id;
|
||||
this.Name = Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -51,7 +47,7 @@ namespace IO.Swagger.Model
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Category {\n");
|
||||
sb.Append(" Id: ").Append(Id).Append("\n");
|
||||
sb.Append(" Name: ").Append(Name).Append("\n");
|
||||
sb.Append(" Name: ").Append(Name).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -39,8 +39,6 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
this.ClassName = ClassName;
|
||||
}
|
||||
|
||||
|
||||
// use default value if no "Color" provided
|
||||
if (Color == null)
|
||||
{
|
||||
@ -50,9 +48,7 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
this.Color = Color;
|
||||
}
|
||||
|
||||
this.Breed = Breed;
|
||||
|
||||
this.Breed = Breed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -79,8 +75,8 @@ namespace IO.Swagger.Model
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Dog {\n");
|
||||
sb.Append(" ClassName: ").Append(ClassName).Append("\n");
|
||||
sb.Append(" Color: ").Append(Color).Append("\n");
|
||||
sb.Append(" Breed: ").Append(Breed).Append("\n");
|
||||
sb.Append(" Color: ").Append(Color).Append("\n");
|
||||
sb.Append(" Breed: ").Append(Breed).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -100,14 +100,9 @@ namespace IO.Swagger.Model
|
||||
/// <param name="EnumNumber">EnumNumber.</param>
|
||||
public EnumTest(EnumStringEnum? EnumString = null, EnumIntegerEnum? EnumInteger = null, EnumNumberEnum? EnumNumber = null)
|
||||
{
|
||||
|
||||
|
||||
this.EnumString = EnumString;
|
||||
|
||||
this.EnumInteger = EnumInteger;
|
||||
|
||||
this.EnumNumber = EnumNumber;
|
||||
|
||||
this.EnumString = EnumString;
|
||||
this.EnumInteger = EnumInteger;
|
||||
this.EnumNumber = EnumNumber;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -119,8 +114,8 @@ namespace IO.Swagger.Model
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class EnumTest {\n");
|
||||
sb.Append(" EnumString: ").Append(EnumString).Append("\n");
|
||||
sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n");
|
||||
sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n");
|
||||
sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n");
|
||||
sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -76,26 +76,15 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
this.Password = Password;
|
||||
}
|
||||
|
||||
|
||||
this.Integer = Integer;
|
||||
|
||||
this.Int32 = Int32;
|
||||
|
||||
this.Int64 = Int64;
|
||||
|
||||
this._Float = _Float;
|
||||
|
||||
this._Double = _Double;
|
||||
|
||||
this._String = _String;
|
||||
|
||||
this.Binary = Binary;
|
||||
|
||||
this.DateTime = DateTime;
|
||||
|
||||
this.Uuid = Uuid;
|
||||
|
||||
this.Integer = Integer;
|
||||
this.Int32 = Int32;
|
||||
this.Int64 = Int64;
|
||||
this._Float = _Float;
|
||||
this._Double = _Double;
|
||||
this._String = _String;
|
||||
this.Binary = Binary;
|
||||
this.DateTime = DateTime;
|
||||
this.Uuid = Uuid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -172,18 +161,18 @@ namespace IO.Swagger.Model
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class FormatTest {\n");
|
||||
sb.Append(" Integer: ").Append(Integer).Append("\n");
|
||||
sb.Append(" Int32: ").Append(Int32).Append("\n");
|
||||
sb.Append(" Int64: ").Append(Int64).Append("\n");
|
||||
sb.Append(" Number: ").Append(Number).Append("\n");
|
||||
sb.Append(" _Float: ").Append(_Float).Append("\n");
|
||||
sb.Append(" _Double: ").Append(_Double).Append("\n");
|
||||
sb.Append(" _String: ").Append(_String).Append("\n");
|
||||
sb.Append(" _Byte: ").Append(_Byte).Append("\n");
|
||||
sb.Append(" Binary: ").Append(Binary).Append("\n");
|
||||
sb.Append(" Date: ").Append(Date).Append("\n");
|
||||
sb.Append(" DateTime: ").Append(DateTime).Append("\n");
|
||||
sb.Append(" Uuid: ").Append(Uuid).Append("\n");
|
||||
sb.Append(" Password: ").Append(Password).Append("\n");
|
||||
sb.Append(" Int32: ").Append(Int32).Append("\n");
|
||||
sb.Append(" Int64: ").Append(Int64).Append("\n");
|
||||
sb.Append(" Number: ").Append(Number).Append("\n");
|
||||
sb.Append(" _Float: ").Append(_Float).Append("\n");
|
||||
sb.Append(" _Double: ").Append(_Double).Append("\n");
|
||||
sb.Append(" _String: ").Append(_String).Append("\n");
|
||||
sb.Append(" _Byte: ").Append(_Byte).Append("\n");
|
||||
sb.Append(" Binary: ").Append(Binary).Append("\n");
|
||||
sb.Append(" Date: ").Append(Date).Append("\n");
|
||||
sb.Append(" DateTime: ").Append(DateTime).Append("\n");
|
||||
sb.Append(" Uuid: ").Append(Uuid).Append("\n");
|
||||
sb.Append(" Password: ").Append(Password).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -23,10 +23,7 @@ namespace IO.Swagger.Model
|
||||
/// <param name="Name">Name.</param>
|
||||
public Model200Response(int? Name = null)
|
||||
{
|
||||
|
||||
|
||||
this.Name = Name;
|
||||
|
||||
this.Name = Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -23,10 +23,7 @@ namespace IO.Swagger.Model
|
||||
/// <param name="_Return">_Return.</param>
|
||||
public ModelReturn(int? _Return = null)
|
||||
{
|
||||
|
||||
|
||||
this._Return = _Return;
|
||||
|
||||
this._Return = _Return;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -38,10 +38,7 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
this._Name = _Name;
|
||||
}
|
||||
|
||||
|
||||
this.Property = Property;
|
||||
|
||||
this.Property = Property;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -73,9 +70,9 @@ namespace IO.Swagger.Model
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Name {\n");
|
||||
sb.Append(" _Name: ").Append(_Name).Append("\n");
|
||||
sb.Append(" SnakeCase: ").Append(SnakeCase).Append("\n");
|
||||
sb.Append(" Property: ").Append(Property).Append("\n");
|
||||
sb.Append(" _123Number: ").Append(_123Number).Append("\n");
|
||||
sb.Append(" SnakeCase: ").Append(SnakeCase).Append("\n");
|
||||
sb.Append(" Property: ").Append(Property).Append("\n");
|
||||
sb.Append(" _123Number: ").Append(_123Number).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -61,18 +61,11 @@ namespace IO.Swagger.Model
|
||||
/// <param name="Complete">Complete (default to false).</param>
|
||||
public Order(long? Id = null, long? PetId = null, int? Quantity = null, DateTime? ShipDate = null, StatusEnum? Status = null, bool? Complete = null)
|
||||
{
|
||||
|
||||
|
||||
this.Id = Id;
|
||||
|
||||
this.PetId = PetId;
|
||||
|
||||
this.Quantity = Quantity;
|
||||
|
||||
this.ShipDate = ShipDate;
|
||||
|
||||
this.Status = Status;
|
||||
|
||||
this.Id = Id;
|
||||
this.PetId = PetId;
|
||||
this.Quantity = Quantity;
|
||||
this.ShipDate = ShipDate;
|
||||
this.Status = Status;
|
||||
// use default value if no "Complete" provided
|
||||
if (Complete == null)
|
||||
{
|
||||
@ -82,7 +75,6 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
this.Complete = Complete;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -119,11 +111,11 @@ namespace IO.Swagger.Model
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Order {\n");
|
||||
sb.Append(" Id: ").Append(Id).Append("\n");
|
||||
sb.Append(" PetId: ").Append(PetId).Append("\n");
|
||||
sb.Append(" Quantity: ").Append(Quantity).Append("\n");
|
||||
sb.Append(" ShipDate: ").Append(ShipDate).Append("\n");
|
||||
sb.Append(" Status: ").Append(Status).Append("\n");
|
||||
sb.Append(" Complete: ").Append(Complete).Append("\n");
|
||||
sb.Append(" PetId: ").Append(PetId).Append("\n");
|
||||
sb.Append(" Quantity: ").Append(Quantity).Append("\n");
|
||||
sb.Append(" ShipDate: ").Append(ShipDate).Append("\n");
|
||||
sb.Append(" Status: ").Append(Status).Append("\n");
|
||||
sb.Append(" Complete: ").Append(Complete).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -84,16 +84,10 @@ namespace IO.Swagger.Model
|
||||
{
|
||||
this.PhotoUrls = PhotoUrls;
|
||||
}
|
||||
|
||||
|
||||
this.Id = Id;
|
||||
|
||||
this.Category = Category;
|
||||
|
||||
this.Tags = Tags;
|
||||
|
||||
this.Status = Status;
|
||||
|
||||
this.Id = Id;
|
||||
this.Category = Category;
|
||||
this.Tags = Tags;
|
||||
this.Status = Status;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -130,11 +124,11 @@ namespace IO.Swagger.Model
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Pet {\n");
|
||||
sb.Append(" Id: ").Append(Id).Append("\n");
|
||||
sb.Append(" Category: ").Append(Category).Append("\n");
|
||||
sb.Append(" Name: ").Append(Name).Append("\n");
|
||||
sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n");
|
||||
sb.Append(" Tags: ").Append(Tags).Append("\n");
|
||||
sb.Append(" Status: ").Append(Status).Append("\n");
|
||||
sb.Append(" Category: ").Append(Category).Append("\n");
|
||||
sb.Append(" Name: ").Append(Name).Append("\n");
|
||||
sb.Append(" PhotoUrls: ").Append(PhotoUrls).Append("\n");
|
||||
sb.Append(" Tags: ").Append(Tags).Append("\n");
|
||||
sb.Append(" Status: ").Append(Status).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -23,10 +23,7 @@ namespace IO.Swagger.Model
|
||||
/// <param name="SpecialPropertyName">SpecialPropertyName.</param>
|
||||
public SpecialModelName(long? SpecialPropertyName = null)
|
||||
{
|
||||
|
||||
|
||||
this.SpecialPropertyName = SpecialPropertyName;
|
||||
|
||||
this.SpecialPropertyName = SpecialPropertyName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -24,12 +24,8 @@ namespace IO.Swagger.Model
|
||||
/// <param name="Name">Name.</param>
|
||||
public Tag(long? Id = null, string Name = null)
|
||||
{
|
||||
|
||||
|
||||
this.Id = Id;
|
||||
|
||||
this.Name = Name;
|
||||
|
||||
this.Id = Id;
|
||||
this.Name = Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -51,7 +47,7 @@ namespace IO.Swagger.Model
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class Tag {\n");
|
||||
sb.Append(" Id: ").Append(Id).Append("\n");
|
||||
sb.Append(" Name: ").Append(Name).Append("\n");
|
||||
sb.Append(" Name: ").Append(Name).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -30,24 +30,14 @@ namespace IO.Swagger.Model
|
||||
/// <param name="UserStatus">User Status.</param>
|
||||
public User(long? Id = null, string Username = null, string FirstName = null, string LastName = null, string Email = null, string Password = null, string Phone = null, int? UserStatus = null)
|
||||
{
|
||||
|
||||
|
||||
this.Id = Id;
|
||||
|
||||
this.Username = Username;
|
||||
|
||||
this.FirstName = FirstName;
|
||||
|
||||
this.LastName = LastName;
|
||||
|
||||
this.Email = Email;
|
||||
|
||||
this.Password = Password;
|
||||
|
||||
this.Phone = Phone;
|
||||
|
||||
this.UserStatus = UserStatus;
|
||||
|
||||
this.Id = Id;
|
||||
this.Username = Username;
|
||||
this.FirstName = FirstName;
|
||||
this.LastName = LastName;
|
||||
this.Email = Email;
|
||||
this.Password = Password;
|
||||
this.Phone = Phone;
|
||||
this.UserStatus = UserStatus;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -100,13 +90,13 @@ namespace IO.Swagger.Model
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class User {\n");
|
||||
sb.Append(" Id: ").Append(Id).Append("\n");
|
||||
sb.Append(" Username: ").Append(Username).Append("\n");
|
||||
sb.Append(" FirstName: ").Append(FirstName).Append("\n");
|
||||
sb.Append(" LastName: ").Append(LastName).Append("\n");
|
||||
sb.Append(" Email: ").Append(Email).Append("\n");
|
||||
sb.Append(" Password: ").Append(Password).Append("\n");
|
||||
sb.Append(" Phone: ").Append(Phone).Append("\n");
|
||||
sb.Append(" UserStatus: ").Append(UserStatus).Append("\n");
|
||||
sb.Append(" Username: ").Append(Username).Append("\n");
|
||||
sb.Append(" FirstName: ").Append(FirstName).Append("\n");
|
||||
sb.Append(" LastName: ").Append(LastName).Append("\n");
|
||||
sb.Append(" Email: ").Append(Email).Append("\n");
|
||||
sb.Append(" Password: ").Append(Password).Append("\n");
|
||||
sb.Append(" Phone: ").Append(Phone).Append("\n");
|
||||
sb.Append(" UserStatus: ").Append(UserStatus).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
@ -1,91 +0,0 @@
|
||||
# IO.Swagger.Api.FakeApi
|
||||
|
||||
All URIs are relative to *http://petstore.swagger.io/v2*
|
||||
|
||||
Method | HTTP request | Description
|
||||
------------- | ------------- | -------------
|
||||
[**TestEndpointParameters**](FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters
|
||||
|
||||
|
||||
# **TestEndpointParameters**
|
||||
> void TestEndpointParameters (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
|
||||
|
||||
Fake endpoint for testing various parameters
|
||||
|
||||
Fake endpoint for testing various parameters
|
||||
|
||||
### Example
|
||||
```csharp
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using IO.Swagger.Api;
|
||||
using IO.Swagger.Client;
|
||||
using IO.Swagger.Model;
|
||||
|
||||
namespace Example
|
||||
{
|
||||
public class TestEndpointParametersExample
|
||||
{
|
||||
public void main()
|
||||
{
|
||||
|
||||
var apiInstance = new FakeApi();
|
||||
var number = 3.4; // double? | None
|
||||
var _double = 1.2; // double? | None
|
||||
var _string = _string_example; // string | None
|
||||
var _byte = B; // byte[] | None
|
||||
var integer = 56; // int? | None (optional)
|
||||
var int32 = 56; // int? | None (optional)
|
||||
var int64 = 789; // long? | None (optional)
|
||||
var _float = 3.4; // float? | None (optional)
|
||||
var binary = B; // byte[] | None (optional)
|
||||
var date = 2013-10-20; // DateTime? | None (optional)
|
||||
var dateTime = 2013-10-20T19:20:30+01:00; // DateTime? | None (optional)
|
||||
var password = password_example; // string | None (optional)
|
||||
|
||||
try
|
||||
{
|
||||
// Fake endpoint for testing various parameters
|
||||
apiInstance.TestEndpointParameters(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Print("Exception when calling FakeApi.TestEndpointParameters: " + e.Message );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------- | ------------- | ------------- | -------------
|
||||
**number** | **double?**| None |
|
||||
**_double** | **double?**| None |
|
||||
**_string** | **string**| None |
|
||||
**_byte** | **byte[]**| None |
|
||||
**integer** | **int?**| None | [optional]
|
||||
**int32** | **int?**| None | [optional]
|
||||
**int64** | **long?**| None | [optional]
|
||||
**_float** | **float?**| None | [optional]
|
||||
**binary** | **byte[]**| None | [optional]
|
||||
**date** | **DateTime?**| None | [optional]
|
||||
**dateTime** | **DateTime?**| None | [optional]
|
||||
**password** | **string**| None | [optional]
|
||||
|
||||
### Return type
|
||||
|
||||
void (empty response body)
|
||||
|
||||
### Authorization
|
||||
|
||||
No authorization required
|
||||
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: application/xml, application/json
|
||||
|
||||
[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md)
|
||||
|
@ -1,418 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using RestSharp;
|
||||
using IO.Swagger.Client;
|
||||
|
||||
namespace IO.Swagger.Api
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// </summary>
|
||||
public interface IFakeApi
|
||||
{
|
||||
#region Synchronous Operations
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </remarks>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns></returns>
|
||||
void TestEndpointParameters (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
|
||||
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </remarks>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns>ApiResponse of Object(void)</returns>
|
||||
ApiResponse<Object> TestEndpointParametersWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
|
||||
#endregion Synchronous Operations
|
||||
#region Asynchronous Operations
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </remarks>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns>Task of void</returns>
|
||||
System.Threading.Tasks.Task TestEndpointParametersAsync (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
|
||||
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Fake endpoint for testing various parameters
|
||||
/// </remarks>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns>Task of ApiResponse</returns>
|
||||
System.Threading.Tasks.Task<ApiResponse<Object>> TestEndpointParametersAsyncWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null);
|
||||
#endregion Asynchronous Operations
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// </summary>
|
||||
public class FakeApi : IFakeApi
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FakeApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public FakeApi(String basePath)
|
||||
{
|
||||
this.Configuration = new Configuration(new ApiClient(basePath));
|
||||
|
||||
// ensure API client has configuration ready
|
||||
if (Configuration.ApiClient.Configuration == null)
|
||||
{
|
||||
this.Configuration.ApiClient.Configuration = this.Configuration;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FakeApi"/> class
|
||||
/// using Configuration object
|
||||
/// </summary>
|
||||
/// <param name="configuration">An instance of Configuration</param>
|
||||
/// <returns></returns>
|
||||
public FakeApi(Configuration configuration = null)
|
||||
{
|
||||
if (configuration == null) // use the default one in Configuration
|
||||
this.Configuration = Configuration.Default;
|
||||
else
|
||||
this.Configuration = configuration;
|
||||
|
||||
// ensure API client has configuration ready
|
||||
if (Configuration.ApiClient.Configuration == null)
|
||||
{
|
||||
this.Configuration.ApiClient.Configuration = this.Configuration;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <value>The base path</value>
|
||||
public String GetBasePath()
|
||||
{
|
||||
return this.Configuration.ApiClient.RestClient.BaseUrl.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the base path of the API client.
|
||||
/// </summary>
|
||||
/// <value>The base path</value>
|
||||
[Obsolete("SetBasePath is deprecated, please do 'Configuraiton.ApiClient = new ApiClient(\"http://new-path\")' instead.")]
|
||||
public void SetBasePath(String basePath)
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the configuration object
|
||||
/// </summary>
|
||||
/// <value>An instance of the Configuration</value>
|
||||
public Configuration Configuration {get; set;}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default header.
|
||||
/// </summary>
|
||||
/// <returns>Dictionary of HTTP header</returns>
|
||||
[Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")]
|
||||
public Dictionary<String, String> DefaultHeader()
|
||||
{
|
||||
return this.Configuration.DefaultHeader;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add default header.
|
||||
/// </summary>
|
||||
/// <param name="key">Header field name.</param>
|
||||
/// <param name="value">Header field value.</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")]
|
||||
public void AddDefaultHeader(string key, string value)
|
||||
{
|
||||
this.Configuration.AddDefaultHeader(key, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns></returns>
|
||||
public void TestEndpointParameters (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
|
||||
{
|
||||
TestEndpointParametersWithHttpInfo(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns>ApiResponse of Object(void)</returns>
|
||||
public ApiResponse<Object> TestEndpointParametersWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
|
||||
{
|
||||
// verify the required parameter 'number' is set
|
||||
if (number == null)
|
||||
throw new ApiException(400, "Missing required parameter 'number' when calling FakeApi->TestEndpointParameters");
|
||||
// verify the required parameter '_double' is set
|
||||
if (_double == null)
|
||||
throw new ApiException(400, "Missing required parameter '_double' when calling FakeApi->TestEndpointParameters");
|
||||
// verify the required parameter '_string' is set
|
||||
if (_string == null)
|
||||
throw new ApiException(400, "Missing required parameter '_string' when calling FakeApi->TestEndpointParameters");
|
||||
// verify the required parameter '_byte' is set
|
||||
if (_byte == null)
|
||||
throw new ApiException(400, "Missing required parameter '_byte' when calling FakeApi->TestEndpointParameters");
|
||||
|
||||
var localVarPath = "/fake";
|
||||
var localVarPathParams = new Dictionary<String, String>();
|
||||
var localVarQueryParams = new Dictionary<String, String>();
|
||||
var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
|
||||
var localVarFormParams = new Dictionary<String, String>();
|
||||
var localVarFileParams = new Dictionary<String, FileParameter>();
|
||||
Object localVarPostBody = null;
|
||||
|
||||
// to determine the Content-Type header
|
||||
String[] localVarHttpContentTypes = new String[] {
|
||||
};
|
||||
String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
|
||||
|
||||
// to determine the Accept header
|
||||
String[] localVarHttpHeaderAccepts = new String[] {
|
||||
"application/xml",
|
||||
"application/json"
|
||||
};
|
||||
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
|
||||
if (localVarHttpHeaderAccept != null)
|
||||
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
|
||||
|
||||
// set "format" to json by default
|
||||
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
|
||||
localVarPathParams.Add("format", "json");
|
||||
if (integer != null) localVarFormParams.Add("integer", Configuration.ApiClient.ParameterToString(integer)); // form parameter
|
||||
if (int32 != null) localVarFormParams.Add("int32", Configuration.ApiClient.ParameterToString(int32)); // form parameter
|
||||
if (int64 != null) localVarFormParams.Add("int64", Configuration.ApiClient.ParameterToString(int64)); // form parameter
|
||||
if (number != null) localVarFormParams.Add("number", Configuration.ApiClient.ParameterToString(number)); // form parameter
|
||||
if (_float != null) localVarFormParams.Add("float", Configuration.ApiClient.ParameterToString(_float)); // form parameter
|
||||
if (_double != null) localVarFormParams.Add("double", Configuration.ApiClient.ParameterToString(_double)); // form parameter
|
||||
if (_string != null) localVarFormParams.Add("string", Configuration.ApiClient.ParameterToString(_string)); // form parameter
|
||||
if (_byte != null) localVarFormParams.Add("byte", Configuration.ApiClient.ParameterToString(_byte)); // form parameter
|
||||
if (binary != null) localVarFormParams.Add("binary", Configuration.ApiClient.ParameterToString(binary)); // form parameter
|
||||
if (date != null) localVarFormParams.Add("date", Configuration.ApiClient.ParameterToString(date)); // form parameter
|
||||
if (dateTime != null) localVarFormParams.Add("dateTime", Configuration.ApiClient.ParameterToString(dateTime)); // form parameter
|
||||
if (password != null) localVarFormParams.Add("password", Configuration.ApiClient.ParameterToString(password)); // form parameter
|
||||
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
|
||||
Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
||||
localVarPathParams, localVarHttpContentType);
|
||||
|
||||
int localVarStatusCode = (int) localVarResponse.StatusCode;
|
||||
|
||||
if (localVarStatusCode >= 400)
|
||||
throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.Content, localVarResponse.Content);
|
||||
else if (localVarStatusCode == 0)
|
||||
throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
|
||||
|
||||
|
||||
return new ApiResponse<Object>(localVarStatusCode,
|
||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
||||
null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns>Task of void</returns>
|
||||
public async System.Threading.Tasks.Task TestEndpointParametersAsync (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
|
||||
{
|
||||
await TestEndpointParametersAsyncWithHttpInfo(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fake endpoint for testing various parameters Fake endpoint for testing various parameters
|
||||
/// </summary>
|
||||
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="number">None</param>
|
||||
/// <param name="_double">None</param>
|
||||
/// <param name="_string">None</param>
|
||||
/// <param name="_byte">None</param>
|
||||
/// <param name="integer">None (optional)</param>
|
||||
/// <param name="int32">None (optional)</param>
|
||||
/// <param name="int64">None (optional)</param>
|
||||
/// <param name="_float">None (optional)</param>
|
||||
/// <param name="binary">None (optional)</param>
|
||||
/// <param name="date">None (optional)</param>
|
||||
/// <param name="dateTime">None (optional)</param>
|
||||
/// <param name="password">None (optional)</param>
|
||||
/// <returns>Task of ApiResponse</returns>
|
||||
public async System.Threading.Tasks.Task<ApiResponse<Object>> TestEndpointParametersAsyncWithHttpInfo (double? number, double? _double, string _string, byte[] _byte, int? integer = null, int? int32 = null, long? int64 = null, float? _float = null, byte[] binary = null, DateTime? date = null, DateTime? dateTime = null, string password = null)
|
||||
{
|
||||
// verify the required parameter 'number' is set
|
||||
if (number == null)
|
||||
throw new ApiException(400, "Missing required parameter 'number' when calling FakeApi->TestEndpointParameters");
|
||||
// verify the required parameter '_double' is set
|
||||
if (_double == null)
|
||||
throw new ApiException(400, "Missing required parameter '_double' when calling FakeApi->TestEndpointParameters");
|
||||
// verify the required parameter '_string' is set
|
||||
if (_string == null)
|
||||
throw new ApiException(400, "Missing required parameter '_string' when calling FakeApi->TestEndpointParameters");
|
||||
// verify the required parameter '_byte' is set
|
||||
if (_byte == null)
|
||||
throw new ApiException(400, "Missing required parameter '_byte' when calling FakeApi->TestEndpointParameters");
|
||||
|
||||
var localVarPath = "/fake";
|
||||
var localVarPathParams = new Dictionary<String, String>();
|
||||
var localVarQueryParams = new Dictionary<String, String>();
|
||||
var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
|
||||
var localVarFormParams = new Dictionary<String, String>();
|
||||
var localVarFileParams = new Dictionary<String, FileParameter>();
|
||||
Object localVarPostBody = null;
|
||||
|
||||
// to determine the Content-Type header
|
||||
String[] localVarHttpContentTypes = new String[] {
|
||||
};
|
||||
String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
|
||||
|
||||
// to determine the Accept header
|
||||
String[] localVarHttpHeaderAccepts = new String[] {
|
||||
"application/xml",
|
||||
"application/json"
|
||||
};
|
||||
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
|
||||
if (localVarHttpHeaderAccept != null)
|
||||
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
|
||||
|
||||
// set "format" to json by default
|
||||
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
|
||||
localVarPathParams.Add("format", "json");
|
||||
if (integer != null) localVarFormParams.Add("integer", Configuration.ApiClient.ParameterToString(integer)); // form parameter
|
||||
if (int32 != null) localVarFormParams.Add("int32", Configuration.ApiClient.ParameterToString(int32)); // form parameter
|
||||
if (int64 != null) localVarFormParams.Add("int64", Configuration.ApiClient.ParameterToString(int64)); // form parameter
|
||||
if (number != null) localVarFormParams.Add("number", Configuration.ApiClient.ParameterToString(number)); // form parameter
|
||||
if (_float != null) localVarFormParams.Add("float", Configuration.ApiClient.ParameterToString(_float)); // form parameter
|
||||
if (_double != null) localVarFormParams.Add("double", Configuration.ApiClient.ParameterToString(_double)); // form parameter
|
||||
if (_string != null) localVarFormParams.Add("string", Configuration.ApiClient.ParameterToString(_string)); // form parameter
|
||||
if (_byte != null) localVarFormParams.Add("byte", Configuration.ApiClient.ParameterToString(_byte)); // form parameter
|
||||
if (binary != null) localVarFormParams.Add("binary", Configuration.ApiClient.ParameterToString(binary)); // form parameter
|
||||
if (date != null) localVarFormParams.Add("date", Configuration.ApiClient.ParameterToString(date)); // form parameter
|
||||
if (dateTime != null) localVarFormParams.Add("dateTime", Configuration.ApiClient.ParameterToString(dateTime)); // form parameter
|
||||
if (password != null) localVarFormParams.Add("password", Configuration.ApiClient.ParameterToString(password)); // form parameter
|
||||
|
||||
|
||||
// make the HTTP request
|
||||
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
|
||||
Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
|
||||
localVarPathParams, localVarHttpContentType);
|
||||
|
||||
int localVarStatusCode = (int) localVarResponse.StatusCode;
|
||||
|
||||
if (localVarStatusCode >= 400)
|
||||
throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.Content, localVarResponse.Content);
|
||||
else if (localVarStatusCode == 0)
|
||||
throw new ApiException (localVarStatusCode, "Error calling TestEndpointParameters: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
|
||||
|
||||
|
||||
return new ApiResponse<Object>(localVarStatusCode,
|
||||
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
|
||||
null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,175 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IO.Swagger.Model
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public class CatDogTest : Cat, IEquatable<CatDogTest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CatDogTest" /> class.
|
||||
/// </summary>
|
||||
public CatDogTest()
|
||||
{
|
||||
this.CatDogInteger = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets CatId
|
||||
/// </summary>
|
||||
[DataMember(Name="cat_id", EmitDefaultValue=false)]
|
||||
public long? CatId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets DogId
|
||||
/// </summary>
|
||||
[DataMember(Name="dog_id", EmitDefaultValue=false)]
|
||||
public long? DogId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// integer property for testing allOf
|
||||
/// </summary>
|
||||
/// <value>integer property for testing allOf</value>
|
||||
[DataMember(Name="CatDogInteger", EmitDefaultValue=false)]
|
||||
public int? CatDogInteger { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets DogName
|
||||
/// </summary>
|
||||
[DataMember(Name="dog_name", EmitDefaultValue=false)]
|
||||
public string DogName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets CatName
|
||||
/// </summary>
|
||||
[DataMember(Name="cat_name", EmitDefaultValue=false)]
|
||||
public string CatName { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>String presentation of the object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class CatDogTest {\n");
|
||||
sb.Append(" CatId: ").Append(CatId).Append("\n");
|
||||
sb.Append(" DogId: ").Append(DogId).Append("\n");
|
||||
sb.Append(" CatDogInteger: ").Append(CatDogInteger).Append("\n");
|
||||
sb.Append(" DogName: ").Append(DogName).Append("\n");
|
||||
sb.Append(" CatName: ").Append(CatName).Append("\n");
|
||||
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the JSON string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public new string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if objects are equal
|
||||
/// </summary>
|
||||
/// <param name="obj">Object to be compared</param>
|
||||
/// <returns>Boolean</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
// credit: http://stackoverflow.com/a/10454552/677735
|
||||
return this.Equals(obj as CatDogTest);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if CatDogTest instances are equal
|
||||
/// </summary>
|
||||
/// <param name="other">Instance of CatDogTest to be compared</param>
|
||||
/// <returns>Boolean</returns>
|
||||
public bool Equals(CatDogTest other)
|
||||
{
|
||||
// credit: http://stackoverflow.com/a/10454552/677735
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
return
|
||||
(
|
||||
this.CatId == other.CatId ||
|
||||
this.CatId != null &&
|
||||
this.CatId.Equals(other.CatId)
|
||||
) &&
|
||||
(
|
||||
this.DogId == other.DogId ||
|
||||
this.DogId != null &&
|
||||
this.DogId.Equals(other.DogId)
|
||||
) &&
|
||||
(
|
||||
this.CatDogInteger == other.CatDogInteger ||
|
||||
this.CatDogInteger != null &&
|
||||
this.CatDogInteger.Equals(other.CatDogInteger)
|
||||
) &&
|
||||
(
|
||||
this.DogName == other.DogName ||
|
||||
this.DogName != null &&
|
||||
this.DogName.Equals(other.DogName)
|
||||
) &&
|
||||
(
|
||||
this.CatName == other.CatName ||
|
||||
this.CatName != null &&
|
||||
this.CatName.Equals(other.CatName)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code
|
||||
/// </summary>
|
||||
/// <returns>Hash code</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
// credit: http://stackoverflow.com/a/263416/677735
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hash = 41;
|
||||
// Suitable nullity checks etc, of course :)
|
||||
|
||||
if (this.CatId != null)
|
||||
hash = hash * 57 + this.CatId.GetHashCode();
|
||||
|
||||
if (this.DogId != null)
|
||||
hash = hash * 57 + this.DogId.GetHashCode();
|
||||
|
||||
if (this.CatDogInteger != null)
|
||||
hash = hash * 57 + this.CatDogInteger.GetHashCode();
|
||||
|
||||
if (this.DogName != null)
|
||||
hash = hash * 57 + this.DogName.GetHashCode();
|
||||
|
||||
if (this.CatName != null)
|
||||
hash = hash * 57 + this.CatName.GetHashCode();
|
||||
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace IO.Swagger.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets EnumClass
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum EnumClass
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Enum Abc for "_abc"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "_abc")]
|
||||
Abc,
|
||||
|
||||
/// <summary>
|
||||
/// Enum efg for "-efg"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "-efg")]
|
||||
efg,
|
||||
|
||||
/// <summary>
|
||||
/// Enum xyz for "(xyz)"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "(xyz)")]
|
||||
xyz
|
||||
}
|
||||
|
||||
}
|
@ -1,199 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace IO.Swagger.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// EnumTest
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public partial class EnumTest : IEquatable<EnumTest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or Sets EnumString
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum EnumStringEnum
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Enum Upper for "UPPER"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "UPPER")]
|
||||
Upper,
|
||||
|
||||
/// <summary>
|
||||
/// Enum Lower for "lower"
|
||||
/// </summary>
|
||||
[EnumMember(Value = "lower")]
|
||||
Lower
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets EnumInteger
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum EnumIntegerEnum
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Enum NUMBER_1 for 1
|
||||
/// </summary>
|
||||
[EnumMember(Value = "1")]
|
||||
NUMBER_1 = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Enum NUMBER_MINUS_1 for -1
|
||||
/// </summary>
|
||||
[EnumMember(Value = "-1")]
|
||||
NUMBER_MINUS_1 = -1
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets EnumNumber
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum EnumNumberEnum
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Enum NUMBER_1_DOT_1 for 1.1
|
||||
/// </summary>
|
||||
[EnumMember(Value = "1.1")]
|
||||
NUMBER_1_DOT_1,
|
||||
|
||||
/// <summary>
|
||||
/// Enum NUMBER_MINUS_1_DOT_2 for -1.2
|
||||
/// </summary>
|
||||
[EnumMember(Value = "-1.2")]
|
||||
NUMBER_MINUS_1_DOT_2
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets EnumString
|
||||
/// </summary>
|
||||
[DataMember(Name="enum_string", EmitDefaultValue=false)]
|
||||
public EnumStringEnum? EnumString { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or Sets EnumInteger
|
||||
/// </summary>
|
||||
[DataMember(Name="enum_integer", EmitDefaultValue=false)]
|
||||
public EnumIntegerEnum? EnumInteger { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or Sets EnumNumber
|
||||
/// </summary>
|
||||
[DataMember(Name="enum_number", EmitDefaultValue=false)]
|
||||
public EnumNumberEnum? EnumNumber { get; set; }
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="EnumTest" /> class.
|
||||
/// </summary>
|
||||
/// <param name="EnumString">EnumString.</param>
|
||||
/// <param name="EnumInteger">EnumInteger.</param>
|
||||
/// <param name="EnumNumber">EnumNumber.</param>
|
||||
public EnumTest(EnumStringEnum? EnumString = null, EnumIntegerEnum? EnumInteger = null, EnumNumberEnum? EnumNumber = null)
|
||||
{
|
||||
|
||||
|
||||
this.EnumString = EnumString;
|
||||
|
||||
this.EnumInteger = EnumInteger;
|
||||
|
||||
this.EnumNumber = EnumNumber;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>String presentation of the object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class EnumTest {\n");
|
||||
sb.Append(" EnumString: ").Append(EnumString).Append("\n");
|
||||
sb.Append(" EnumInteger: ").Append(EnumInteger).Append("\n");
|
||||
sb.Append(" EnumNumber: ").Append(EnumNumber).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the JSON string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if objects are equal
|
||||
/// </summary>
|
||||
/// <param name="obj">Object to be compared</param>
|
||||
/// <returns>Boolean</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
// credit: http://stackoverflow.com/a/10454552/677735
|
||||
return this.Equals(obj as EnumTest);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if EnumTest instances are equal
|
||||
/// </summary>
|
||||
/// <param name="other">Instance of EnumTest to be compared</param>
|
||||
/// <returns>Boolean</returns>
|
||||
public bool Equals(EnumTest other)
|
||||
{
|
||||
// credit: http://stackoverflow.com/a/10454552/677735
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
return
|
||||
(
|
||||
this.EnumString == other.EnumString ||
|
||||
this.EnumString != null &&
|
||||
this.EnumString.Equals(other.EnumString)
|
||||
) &&
|
||||
(
|
||||
this.EnumInteger == other.EnumInteger ||
|
||||
this.EnumInteger != null &&
|
||||
this.EnumInteger.Equals(other.EnumInteger)
|
||||
) &&
|
||||
(
|
||||
this.EnumNumber == other.EnumNumber ||
|
||||
this.EnumNumber != null &&
|
||||
this.EnumNumber.Equals(other.EnumNumber)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code
|
||||
/// </summary>
|
||||
/// <returns>Hash code</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
// credit: http://stackoverflow.com/a/263416/677735
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hash = 41;
|
||||
// Suitable nullity checks etc, of course :)
|
||||
if (this.EnumString != null)
|
||||
hash = hash * 59 + this.EnumString.GetHashCode();
|
||||
if (this.EnumInteger != null)
|
||||
hash = hash * 59 + this.EnumInteger.GetHashCode();
|
||||
if (this.EnumNumber != null)
|
||||
hash = hash * 59 + this.EnumNumber.GetHashCode();
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,143 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace IO.Swagger.Model
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[DataContract]
|
||||
public class TagCategoryTest : Category, IEquatable<TagCategoryTest>
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TagCategoryTest" /> class.
|
||||
/// </summary>
|
||||
public TagCategoryTest()
|
||||
{
|
||||
this.TagCategoryInteger = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
/// </summary>
|
||||
[DataMember(Name="id", EmitDefaultValue=false)]
|
||||
public long? Id { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// integer property for testing allOf
|
||||
/// </summary>
|
||||
/// <value>integer property for testing allOf</value>
|
||||
[DataMember(Name="TagCategoryInteger", EmitDefaultValue=false)]
|
||||
public int? TagCategoryInteger { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets Name
|
||||
/// </summary>
|
||||
[DataMember(Name="name", EmitDefaultValue=false)]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>String presentation of the object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("class TagCategoryTest {\n");
|
||||
sb.Append(" Id: ").Append(Id).Append("\n");
|
||||
sb.Append(" TagCategoryInteger: ").Append(TagCategoryInteger).Append("\n");
|
||||
sb.Append(" Name: ").Append(Name).Append("\n");
|
||||
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the JSON string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public new string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if objects are equal
|
||||
/// </summary>
|
||||
/// <param name="obj">Object to be compared</param>
|
||||
/// <returns>Boolean</returns>
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
// credit: http://stackoverflow.com/a/10454552/677735
|
||||
return this.Equals(obj as TagCategoryTest);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if TagCategoryTest instances are equal
|
||||
/// </summary>
|
||||
/// <param name="other">Instance of TagCategoryTest to be compared</param>
|
||||
/// <returns>Boolean</returns>
|
||||
public bool Equals(TagCategoryTest other)
|
||||
{
|
||||
// credit: http://stackoverflow.com/a/10454552/677735
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
return
|
||||
(
|
||||
this.Id == other.Id ||
|
||||
this.Id != null &&
|
||||
this.Id.Equals(other.Id)
|
||||
) &&
|
||||
(
|
||||
this.TagCategoryInteger == other.TagCategoryInteger ||
|
||||
this.TagCategoryInteger != null &&
|
||||
this.TagCategoryInteger.Equals(other.TagCategoryInteger)
|
||||
) &&
|
||||
(
|
||||
this.Name == other.Name ||
|
||||
this.Name != null &&
|
||||
this.Name.Equals(other.Name)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code
|
||||
/// </summary>
|
||||
/// <returns>Hash code</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
// credit: http://stackoverflow.com/a/263416/677735
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hash = 41;
|
||||
// Suitable nullity checks etc, of course :)
|
||||
|
||||
if (this.Id != null)
|
||||
hash = hash * 57 + this.Id.GetHashCode();
|
||||
|
||||
if (this.TagCategoryInteger != null)
|
||||
hash = hash * 57 + this.TagCategoryInteger.GetHashCode();
|
||||
|
||||
if (this.Name != null)
|
||||
hash = hash * 57 + this.Name.GetHashCode();
|
||||
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1011E844-3414-4D65-BF1F-7C8CE0167174}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>SwaggerClientTest</RootNamespace>
|
||||
<AssemblyName>SwaggerClientTest</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp">
|
||||
<HintPath>packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="TestPet.cs" />
|
||||
<Compile Include="TestApiClient.cs" />
|
||||
<Compile Include="TestConfiguration.cs" />
|
||||
<Compile Include="TestOrder.cs" />
|
||||
<Compile Include="TestEnum.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<None Include="..\SwaggerClient\build.bat" />
|
||||
<None Include="..\SwaggerClient\build.sh" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="..\SwaggerClient\" />
|
||||
<EmbeddedResource Include="swagger-logo.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SwaggerClient\src\IO.Swagger\IO.Swagger.csproj">
|
||||
<Project>{0862164F-97E9-4226-B458-E09905B21F2F}</Project>
|
||||
<Name>IO.Swagger</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,23 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwaggerClientTest", "SwaggerClientTest.csproj", "{1011E844-3414-4D65-BF1F-7C8CE0167174}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "..\SwaggerClient\src\IO.Swagger\IO.Swagger.csproj", "{0862164F-97E9-4226-B458-E09905B21F2F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{0862164F-97E9-4226-B458-E09905B21F2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0862164F-97E9-4226-B458-E09905B21F2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0862164F-97E9-4226-B458-E09905B21F2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0862164F-97E9-4226-B458-E09905B21F2F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1011E844-3414-4D65-BF1F-7C8CE0167174}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1011E844-3414-4D65-BF1F-7C8CE0167174}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1011E844-3414-4D65-BF1F-7C8CE0167174}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1011E844-3414-4D65-BF1F-7C8CE0167174}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1,15 +0,0 @@
|
||||
<Properties StartupItem="SwaggerClientTest.csproj">
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="../SwaggerClient/src/IO.Swagger/Model/ApiResponse.cs">
|
||||
<Files>
|
||||
<File FileName="TestPet.cs" Line="1" Column="1" />
|
||||
<File FileName="TestOrder.cs" Line="1" Column="1" />
|
||||
<File FileName="../SwaggerClient/src/IO.Swagger/Api/FakeApi.cs" Line="1" Column="1" />
|
||||
<File FileName="../SwaggerClient/src/IO.Swagger/Model/ApiResponse.cs" Line="13" Column="2" />
|
||||
</Files>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
<BreakpointStore />
|
||||
</MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
|
||||
</Properties>
|
@ -1,39 +0,0 @@
|
||||
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.TestEnum
|
||||
{
|
||||
[TestFixture ()]
|
||||
public class TestEnum
|
||||
{
|
||||
public TestEnum ()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test EnumClass
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestEnumClass ()
|
||||
{
|
||||
// test serialization for string
|
||||
Assert.AreEqual (Newtonsoft.Json.JsonConvert.SerializeObject(EnumClass.Abc), "\"_abc\"");
|
||||
|
||||
// test serialization for number
|
||||
Assert.AreEqual (Newtonsoft.Json.JsonConvert.SerializeObject(EnumTest.EnumIntegerEnum.NUMBER_MINUS_1), "\"-1\"");
|
||||
|
||||
// test cast to int
|
||||
Assert.AreEqual ((int)EnumTest.EnumIntegerEnum.NUMBER_MINUS_1, -1);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,112 +0,0 @@
|
||||
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 ()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <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);
|
||||
Assert.AreEqual (Order.StatusEnum.Placed, o.Status);
|
||||
Assert.AreEqual (true, o.Complete);
|
||||
|
||||
}
|
||||
|
||||
/// <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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Skip the following test as the fake endpiont has been removed from the swagger spec
|
||||
* We'll uncomment below after we update the Petstore server
|
||||
/// <summary>
|
||||
/// Test TestGetInventoryInObject
|
||||
/// </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));
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Test Enum
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestEnum ()
|
||||
{
|
||||
Assert.AreEqual (Order.StatusEnum.Approved.ToString(), "Approved");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,386 +0,0 @@
|
||||
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;
|
||||
|
||||
namespace SwaggerClientTest.TestPet
|
||||
{
|
||||
[TestFixture ()]
|
||||
public class TestPet
|
||||
{
|
||||
public long petId = 11088;
|
||||
|
||||
/// <summary>
|
||||
/// Create a Pet object
|
||||
/// </summary>
|
||||
private Pet createPet()
|
||||
{
|
||||
// create pet
|
||||
Pet p = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test" });
|
||||
p.Id = petId;
|
||||
//p.Name = "Csharp test";
|
||||
p.Status = Pet.StatusEnum.Available;
|
||||
// create Category object
|
||||
Category category = new Category();
|
||||
category.Id = 56;
|
||||
category.Name = "sample category name2";
|
||||
List<String> photoUrls = new List<String>(new String[] {"sample photoUrls"});
|
||||
// create Tag object
|
||||
Tag tag = new Tag();
|
||||
tag.Id = petId;
|
||||
tag.Name = "csharp sample tag name1";
|
||||
List<Tag> tags = new List<Tag>(new Tag[] {tag});
|
||||
p.Tags = tags;
|
||||
p.Category = category;
|
||||
p.PhotoUrls = photoUrls;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert string to byte array
|
||||
/// </summary>
|
||||
private byte[] GetBytes(string str)
|
||||
{
|
||||
byte[] bytes = new byte[str.Length * sizeof(char)];
|
||||
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
[SetUp] public void Init()
|
||||
{
|
||||
// create pet
|
||||
Pet p = createPet();
|
||||
|
||||
// add pet before testing
|
||||
PetApi petApi = new PetApi("http://petstore.swagger.io/v2/");
|
||||
petApi.AddPet (p);
|
||||
|
||||
}
|
||||
|
||||
[TearDown] public void Cleanup()
|
||||
{
|
||||
// remove the pet after testing
|
||||
PetApi petApi = new PetApi ();
|
||||
petApi.DeletePet(petId, "test key");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test GetPetByIdAsync
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestGetPetByIdAsync ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
var task = petApi.GetPetByIdAsync (petId);
|
||||
Pet response = task.Result;
|
||||
Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
|
||||
|
||||
Assert.AreEqual ("Csharp test", response.Name);
|
||||
Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
|
||||
|
||||
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
|
||||
Assert.AreEqual (petId, response.Tags [0].Id);
|
||||
Assert.AreEqual ("csharp sample tag name1", response.Tags [0].Name);
|
||||
|
||||
Assert.IsInstanceOf<List<String>> (response.PhotoUrls, "Response.PhotoUrls is a Array");
|
||||
Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
|
||||
|
||||
Assert.IsInstanceOf<Category> (response.Category, "Response.Category is a Category");
|
||||
Assert.AreEqual (56, response.Category.Id);
|
||||
Assert.AreEqual ("sample category name2", response.Category.Name);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test GetPetByIdAsyncWithHttpInfo
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestGetPetByIdAsyncWithHttpInfo ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
var task = petApi.GetPetByIdAsyncWithHttpInfo (petId);
|
||||
|
||||
Assert.AreEqual (200, task.Result.StatusCode);
|
||||
Assert.IsTrue (task.Result.Headers.ContainsKey("Content-Type"));
|
||||
Assert.AreEqual (task.Result.Headers["Content-Type"], "application/json");
|
||||
|
||||
Pet response = task.Result.Data;
|
||||
Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
|
||||
|
||||
Assert.AreEqual ("Csharp test", response.Name);
|
||||
Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
|
||||
|
||||
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
|
||||
Assert.AreEqual (petId, response.Tags [0].Id);
|
||||
Assert.AreEqual ("csharp sample tag name1", response.Tags [0].Name);
|
||||
|
||||
Assert.IsInstanceOf<List<String>> (response.PhotoUrls, "Response.PhotoUrls is a Array");
|
||||
Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
|
||||
|
||||
Assert.IsInstanceOf<Category> (response.Category, "Response.Category is a Category");
|
||||
Assert.AreEqual (56, response.Category.Id);
|
||||
Assert.AreEqual ("sample category name2", response.Category.Name);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test GetPetById
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestGetPetById ()
|
||||
{
|
||||
// set timeout to 10 seconds
|
||||
Configuration c1 = new Configuration (timeout: 10000, userAgent: "TEST_USER_AGENT");
|
||||
|
||||
PetApi petApi = new PetApi (c1);
|
||||
Pet response = petApi.GetPetById (petId);
|
||||
Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
|
||||
|
||||
Assert.AreEqual ("Csharp test", response.Name);
|
||||
Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
|
||||
|
||||
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
|
||||
Assert.AreEqual (petId, response.Tags [0].Id);
|
||||
Assert.AreEqual ("csharp sample tag name1", response.Tags [0].Name);
|
||||
|
||||
Assert.IsInstanceOf<List<String>> (response.PhotoUrls, "Response.PhotoUrls is a Array");
|
||||
Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
|
||||
|
||||
Assert.IsInstanceOf<Category> (response.Category, "Response.Category is a Category");
|
||||
Assert.AreEqual (56, response.Category.Id);
|
||||
Assert.AreEqual ("sample category name2", response.Category.Name);
|
||||
|
||||
}
|
||||
|
||||
/* 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
|
||||
*
|
||||
/// <summary>
|
||||
/// Test GetPetByIdInObject
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestGetPetByIdInObject ()
|
||||
{
|
||||
// set timeout to 10 seconds
|
||||
Configuration c1 = new Configuration (timeout: 10000);
|
||||
|
||||
PetApi petApi = new PetApi (c1);
|
||||
InlineResponse200 response = petApi.GetPetByIdInObject (petId);
|
||||
Assert.IsInstanceOf<InlineResponse200> (response, "Response is a Pet");
|
||||
|
||||
Assert.AreEqual ("Csharp test", response.Name);
|
||||
Assert.AreEqual (InlineResponse200.StatusEnum.Available, response.Status);
|
||||
|
||||
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
|
||||
Assert.AreEqual (petId, response.Tags [0].Id);
|
||||
Assert.AreEqual ("csharp sample tag name1", response.Tags [0].Name);
|
||||
|
||||
Assert.IsInstanceOf<List<String>> (response.PhotoUrls, "Response.PhotoUrls is a Array");
|
||||
Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
|
||||
|
||||
Assert.IsInstanceOf<Newtonsoft.Json.Linq.JObject> (response.Category, "Response.Category is a Newtonsoft.Json.Linq.JObject");
|
||||
|
||||
Newtonsoft.Json.Linq.JObject category = (Newtonsoft.Json.Linq.JObject)response.Category;
|
||||
Assert.AreEqual (56, (int)category ["id"]);
|
||||
Assert.AreEqual ("sample category name2", (string) category["name"]);
|
||||
|
||||
}*/
|
||||
|
||||
/* 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
|
||||
*
|
||||
/// <summary>
|
||||
/// Test GetPetByIdWithByteArray
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestGetPetByIdWithByteArray ()
|
||||
{
|
||||
// set timeout to 10 seconds
|
||||
Configuration c1 = new Configuration (timeout: 10000);
|
||||
|
||||
PetApi petApi = new PetApi (c1);
|
||||
byte[] response = petApi.PetPetIdtestingByteArraytrueGet (petId);
|
||||
Assert.IsInstanceOf<byte[]> (response, "Response is byte array");
|
||||
}*/
|
||||
|
||||
/* 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
|
||||
*
|
||||
/// <summary>
|
||||
/// Test AddPetUsingByteArray
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestAddPetUsingByteArray ()
|
||||
{
|
||||
// set timeout to 10 seconds
|
||||
Configuration c1 = new Configuration (timeout: 10000);
|
||||
|
||||
PetApi petApi = new PetApi (c1);
|
||||
Pet p = createPet ();
|
||||
byte[] petByteArray = GetBytes ((string)petApi.Configuration.ApiClient.Serialize (p));
|
||||
petApi.AddPetUsingByteArray (petByteArray);
|
||||
}*/
|
||||
|
||||
/// <summary>
|
||||
/// Test UpdatePetWithForm
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestUpdatePetWithForm ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
petApi.UpdatePetWithForm (petId, "new form name", "pending");
|
||||
|
||||
Pet response = petApi.GetPetById (petId);
|
||||
Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
|
||||
Assert.IsInstanceOf<Category> (response.Category, "Response.Category is a Category");
|
||||
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
|
||||
|
||||
Assert.AreEqual ("new form name", response.Name);
|
||||
Assert.AreEqual (Pet.StatusEnum.Pending, response.Status);
|
||||
|
||||
Assert.AreEqual (petId, response.Tags [0].Id);
|
||||
Assert.AreEqual (56, response.Category.Id);
|
||||
|
||||
// test optional parameter
|
||||
petApi.UpdatePetWithForm (petId, "new form name2");
|
||||
Pet response2 = petApi.GetPetById (petId);
|
||||
Assert.AreEqual ("new form name2", response2.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test UploadFile
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestUploadFile ()
|
||||
{
|
||||
Assembly _assembly = Assembly.GetExecutingAssembly();
|
||||
Stream _imageStream = _assembly.GetManifestResourceStream("SwaggerClientTest.swagger-logo.png");
|
||||
PetApi petApi = new PetApi ();
|
||||
// test file upload with form parameters
|
||||
petApi.UploadFile(petId, "new form name", _imageStream);
|
||||
|
||||
// test file upload without any form parameters
|
||||
// using optional parameter syntax introduced at .net 4.0
|
||||
petApi.UploadFile(petId: petId, file: _imageStream);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test FindPetByStatus
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestFindPetByTags ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
List<String> tagsList = new List<String>(new String[] {"available"});
|
||||
|
||||
List<Pet> listPet = petApi.FindPetsByTags (tagsList);
|
||||
foreach (Pet pet in listPet) // Loop through List with foreach.
|
||||
{
|
||||
Assert.IsInstanceOf<Pet> (pet, "Response is a Pet");
|
||||
Assert.AreEqual ("csharp sample tag name1", pet.Tags[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test Equal
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestEqual()
|
||||
{
|
||||
// create pet
|
||||
Pet p1 = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test"} );
|
||||
p1.Id = petId;
|
||||
//p1.Name = "Csharp test";
|
||||
p1.Status = Pet.StatusEnum.Available;
|
||||
// create Category object
|
||||
Category category1 = new Category();
|
||||
category1.Id = 56;
|
||||
category1.Name = "sample category name2";
|
||||
List<String> photoUrls1 = new List<String>(new String[] {"sample photoUrls"});
|
||||
// create Tag object
|
||||
Tag tag1 = new Tag();
|
||||
tag1.Id = petId;
|
||||
tag1.Name = "csharp sample tag name1";
|
||||
List<Tag> tags1 = new List<Tag>(new Tag[] {tag1});
|
||||
p1.Tags = tags1;
|
||||
p1.Category = category1;
|
||||
p1.PhotoUrls = photoUrls1;
|
||||
|
||||
// create pet 2
|
||||
Pet p2 = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test"} );
|
||||
p2.Id = petId;
|
||||
p2.Name = "Csharp test";
|
||||
p2.Status = Pet.StatusEnum.Available;
|
||||
// create Category object
|
||||
Category category2 = new Category();
|
||||
category2.Id = 56;
|
||||
category2.Name = "sample category name2";
|
||||
List<String> photoUrls2 = new List<String>(new String[] {"sample photoUrls"});
|
||||
// create Tag object
|
||||
Tag tag2 = new Tag();
|
||||
tag2.Id = petId;
|
||||
tag2.Name = "csharp sample tag name1";
|
||||
List<Tag> tags2 = new List<Tag>(new Tag[] {tag2});
|
||||
p2.Tags = tags2;
|
||||
p2.Category = category2;
|
||||
p2.PhotoUrls = photoUrls2;
|
||||
|
||||
// p1 and p2 should be equal (both object and attribute level)
|
||||
Assert.IsTrue (category1.Equals (category2));
|
||||
Assert.IsTrue (tags1.SequenceEqual (tags2));
|
||||
Assert.IsTrue (p1.PhotoUrls.SequenceEqual(p2.PhotoUrls));
|
||||
|
||||
Assert.IsTrue (p1.Equals (p2));
|
||||
|
||||
// update attribute to that p1 and p2 are not equal
|
||||
category2.Name = "new category name";
|
||||
Assert.IsFalse(category1.Equals (category2));
|
||||
|
||||
tags2 = new List<Tag> ();
|
||||
Assert.IsFalse (tags1.SequenceEqual (tags2));
|
||||
|
||||
// photoUrls has not changed so it should be equal
|
||||
Assert.IsTrue (p1.PhotoUrls.SequenceEqual(p2.PhotoUrls));
|
||||
|
||||
Assert.IsFalse (p1.Equals (p2));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test status code
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestStatusCodeAndHeader ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
var response = petApi.GetPetByIdWithHttpInfo (petId);
|
||||
Assert.AreEqual (response.StatusCode, 200);
|
||||
Assert.IsTrue (response.Headers.ContainsKey("Content-Type"));
|
||||
Assert.AreEqual (response.Headers["Content-Type"], "application/json");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test default header (should be deprecated
|
||||
/// </summary>
|
||||
[Test ()]
|
||||
public void TestDefaultHeader ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
// commented out the warning test below as it's confirmed the warning is working as expected
|
||||
// there should be a warning for using AddDefaultHeader (deprecated) below
|
||||
//petApi.AddDefaultHeader ("header_key", "header_value");
|
||||
// the following should be used instead as suggested in the doc
|
||||
petApi.Configuration.AddDefaultHeader ("header_key2", "header_value2");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
wget -nc https://nuget.org/nuget.exe;
|
||||
mozroots --import --sync
|
||||
|
||||
# remove bin/Debug/SwaggerClientTest.dll
|
||||
rm bin/Debug/SwaggerClientTest.dll 2> /dev/null
|
||||
|
||||
# install NUnit runners via NuGet
|
||||
mono nuget.exe install NUnit.Runners -Version 2.6.4 -OutputDirectory testrunner
|
||||
|
||||
# build the solution and run the unit test
|
||||
xbuild SwaggerClientTest.sln && \
|
||||
mono ./testrunner/NUnit.Runners.2.6.4/tools/nunit-console.exe bin/Debug/SwaggerClientTest.dll
|
||||
|
@ -1,11 +0,0 @@
|
||||
/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
|
||||
/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.swagger-logo.png
|
||||
/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb
|
||||
/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll
|
||||
/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll
|
||||
/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb
|
||||
/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll
|
||||
/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll
|
||||
/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll
|
||||
/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Swagger Library.dll
|
||||
/Users/williamcheng/Code/swagger-api/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Swagger Library.dll.mdb
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="2.6.4" targetFramework="net45" />
|
||||
<package id="RestSharp" version="105.1.0" targetFramework="net45" developmentDependency="true" />
|
||||
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net45" developmentDependency="true" />
|
||||
</packages>
|
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -1,15 +0,0 @@
|
||||
Copyright © 2002-2014 Charlie Poole
|
||||
Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
|
||||
Copyright © 2000-2002 Philip A. Craig
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment (see the following) in the product documentation is required.
|
||||
|
||||
Portions Copyright © 2002-2014 Charlie Poole or Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov or Copyright © 2000-2002 Philip A. Craig
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
@ -1,5 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<repositories>
|
||||
<repository path="../../SwaggerClient/src/IO.Swagger/packages.config" />
|
||||
<repository path="../packages.config" />
|
||||
</repositories>
|
@ -1,56 +0,0 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.wordnik</groupId>
|
||||
<artifactId>CsharpPetstoreClientTests</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>C# Swagger Petstore Client</name>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<executions>
|
||||
<!--execution>
|
||||
<id>bundle-install</id>
|
||||
<phase>pre-integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>bundle</executable>
|
||||
<arguments>
|
||||
<argument>install</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</execution-->
|
||||
<execution>
|
||||
<id>mono-test</id>
|
||||
<phase>integration-test</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<executable>mono-nunit.sh</executable>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
Loading…
Reference in New Issue
Block a user