Merge remote-tracking branch 'main/master'

This commit is contained in:
Tommy Alander
2016-02-29 08:24:31 +01:00
1738 changed files with 71972 additions and 42877 deletions

View File

@@ -15,12 +15,15 @@ namespace SwaggerClientTest.TestPet
{
public long petId = 11088;
[SetUp] public void Init()
/// <summary>
/// Create a Pet object
/// </summary>
private Pet createPet()
{
// create pet
Pet p = new 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.Name = "Csharp test";
p.Status = "available";
// create Category object
Category category = new Category();
@@ -30,12 +33,30 @@ namespace SwaggerClientTest.TestPet
// create Tag object
Tag tag = new Tag();
tag.Id = petId;
tag.Name = "sample tag name1";
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);
@@ -65,7 +86,7 @@ namespace SwaggerClientTest.TestPet
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
Assert.AreEqual (petId, response.Tags [0].Id);
Assert.AreEqual ("sample tag name1", response.Tags [0].Name);
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]);
@@ -97,7 +118,7 @@ namespace SwaggerClientTest.TestPet
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
Assert.AreEqual (petId, response.Tags [0].Id);
Assert.AreEqual ("sample tag name1", response.Tags [0].Name);
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]);
@@ -126,7 +147,7 @@ namespace SwaggerClientTest.TestPet
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
Assert.AreEqual (petId, response.Tags [0].Id);
Assert.AreEqual ("sample tag name1", response.Tags [0].Name);
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]);
@@ -137,6 +158,35 @@ namespace SwaggerClientTest.TestPet
}
/// <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");
}
/// <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>
@@ -171,7 +221,7 @@ namespace SwaggerClientTest.TestPet
{
Assembly _assembly = Assembly.GetExecutingAssembly();
Stream _imageStream = _assembly.GetManifestResourceStream("SwaggerClientTest.swagger-logo.png");
PetApi petApi = new PetApi ();
PetApi petApi = new PetApi ();
// test file upload with form parameters
petApi.UploadFile(petId, "new form name", _imageStream);
@@ -185,16 +235,16 @@ namespace SwaggerClientTest.TestPet
/// Test FindPetByStatus
/// </summary>
[Test ()]
public void TestFindPetByStatus ()
public void TestFindPetByTags ()
{
PetApi petApi = new PetApi ();
List<String> statusList = new List<String>(new String[] {"available"});
List<String> tagsList = new List<String>(new String[] {"available"});
List<Pet> listPet = petApi.FindPetsByStatus (statusList);
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 ("available", pet.Status);
Assert.AreEqual ("csharp sample tag name1", pet.Tags[0]);
}
}
@@ -206,9 +256,9 @@ namespace SwaggerClientTest.TestPet
public void TestEqual()
{
// create pet
Pet p1 = new 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.Name = "Csharp test";
p1.Status = "available";
// create Category object
Category category1 = new Category();
@@ -218,14 +268,14 @@ namespace SwaggerClientTest.TestPet
// create Tag object
Tag tag1 = new Tag();
tag1.Id = petId;
tag1.Name = "sample tag name1";
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();
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 = "available";
@@ -237,7 +287,7 @@ namespace SwaggerClientTest.TestPet
// create Tag object
Tag tag2 = new Tag();
tag2.Id = petId;
tag2.Name = "sample tag name1";
tag2.Name = "csharp sample tag name1";
List<Tag> tags2 = new List<Tag>(new Tag[] {tag2});
p2.Tags = tags2;
p2.Category = category2;
@@ -284,8 +334,9 @@ namespace SwaggerClientTest.TestPet
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");
//petApi.AddDefaultHeader ("header_key", "header_value");
// the following should be used instead as suggested in the doc
petApi.Configuration.AddDefaultHeader ("header_key2", "header_value2");