本文整理汇总了C#中IO.Swagger.Api.PetApi类的典型用法代码示例。如果您正苦于以下问题:C# PetApi类的具体用法?C# PetApi怎么用?C# PetApi使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PetApi类属于IO.Swagger.Api命名空间,在下文中一共展示了PetApi类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetPetByIdAsyncWithHttpInfo
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 ("available", response.Status);
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.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);
}
示例2: Init
public void Init()
{
// create pet
Pet p = new Pet();
p.Id = petId;
p.Name = "Csharp test";
p.Status = "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 = "sample tag name1";
List<Tag> tags = new List<Tag>(new Tag[] {tag});
p.Tags = tags;
p.Category = category;
p.PhotoUrls = photoUrls;
// add pet before testing
PetApi petApi = new PetApi("http://petstore.swagger.io/v2/");
petApi.AddPet (p);
}
示例3: TestDefaultHeader
public void TestDefaultHeader()
{
PetApi petApi = new PetApi ();
// 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");
}
示例4: TestBasePath
public void TestBasePath ()
{
PetApi p = new PetApi ("http://new-basepath.com");
Assert.AreEqual (p.Configuration.ApiClient.RestClient.BaseUrl, "http://new-basepath.com");
// Given that PetApi is initailized with a base path, a new configuration (with a new ApiClient)
// is created by default
Assert.AreNotSame (p.Configuration, Configuration.Default);
}
示例5: TestDefaultHeader
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: Init
public void Init()
{
// create pet
Pet p = createPet();
// add pet before testing
PetApi petApi = new PetApi("http://petstore.swagger.io/v2/");
petApi.AddPet (p);
}
示例7: TestAddPetUsingByteArray
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);
}
示例8: TestFindPetByStatus
public void TestFindPetByStatus()
{
PetApi petApi = new PetApi ();
List<String> statusList = new List<String>(new String[] {"available"});
List<Pet> listPet = petApi.FindPetsByStatus (statusList);
foreach (Pet pet in listPet) // Loop through List with foreach.
{
Assert.IsInstanceOf<Pet> (pet, "Response is a Pet");
Assert.AreEqual ("available", pet.Status);
}
}
示例9: FindPetsByStatusTest
public void FindPetsByStatusTest()
{
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]);
}
}
示例10: TestDefautlConfiguration
public void TestDefautlConfiguration()
{
PetApi p1 = new PetApi ();
PetApi p2 = new PetApi ();
Assert.AreSame (p1.Configuration, p2.Configuration);
// same as the default
Assert.AreSame (p1.Configuration, Configuration.Default);
Configuration c = new Configuration ();
Assert.AreNotSame (c, p1.Configuration);
PetApi p3 = new PetApi (c);
// same as c
Assert.AreSame (p3.Configuration, c);
// not same as default
Assert.AreNotSame (p3.Configuration, p1.Configuration);
}
示例11: TestGetPetById
public void TestGetPetById()
{
PetApi petApi = new PetApi ();
Pet response = petApi.GetPetById (petId);
Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
Assert.AreEqual ("Csharp test", response.Name);
Assert.AreEqual ("available", response.Status);
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.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);
}
示例12: TestUsage
public void TestUsage()
{
// basic use case using default base URL
PetApi p1 = new PetApi ();
Assert.AreSame (p1.Configuration, Configuration.Default, "PetApi should use default configuration");
// using a different base URL
PetApi p2 = new PetApi ("http://new-base-url.com/");
Assert.AreEqual (p2.Configuration.ApiClient.RestClient.BaseUrl.ToString(), "http://new-base-url.com/");
// using a different configuration
Configuration c1 = new Configuration ();
PetApi p3 = new PetApi (c1);
Assert.AreSame (p3.Configuration, c1);
// using a different base URL via a new ApiClient
ApiClient a1 = new ApiClient ("http://new-api-client.com");
Configuration c2 = new Configuration (a1);
PetApi p4 = new PetApi (c2);
Assert.AreSame (p4.Configuration.ApiClient, a1);
}
示例13: UploadFileTest
public void UploadFileTest()
{
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);
}
示例14: Init
public void Init()
{
instance = new PetApi();
}
示例15: TestApiClientInstance
public void TestApiClientInstance ()
{
PetApi p1 = new PetApi ();
PetApi p2 = new PetApi ();
Configuration c1 = new Configuration (); // using default ApiClient
PetApi p3 = new PetApi (c1);
ApiClient a1 = new ApiClient();
Configuration c2 = new Configuration (a1); // using "a1" as the ApiClient
PetApi p4 = new PetApi (c2);
// ensure both using the same default ApiClient
Assert.AreSame(p1.Configuration.ApiClient, p2.Configuration.ApiClient);
Assert.AreSame(p1.Configuration.ApiClient, Configuration.Default.ApiClient);
// ensure both using the same default ApiClient
Assert.AreSame(p3.Configuration.ApiClient, c1.ApiClient);
Assert.AreSame(p3.Configuration.ApiClient, Configuration.Default.ApiClient);
// ensure it's not using the default ApiClient
Assert.AreSame(p4.Configuration.ApiClient, c2.ApiClient);
Assert.AreNotSame(p4.Configuration.ApiClient, Configuration.Default.ApiClient);
}