当前位置: 首页>>代码示例>>C#>>正文


C# Api.PetApi类代码示例

本文整理汇总了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);

		}
开发者ID:frinux,项目名称:swagger-codegen,代码行数:27,代码来源:TestPet.cs

示例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);
        }
开发者ID:DariusMR,项目名称:swagger-codegen,代码行数:25,代码来源:TestPet.cs

示例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");
 }
开发者ID:romerod,项目名称:swagger-codegen,代码行数:8,代码来源:TestPet.cs

示例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);
		}
开发者ID:Roustalski,项目名称:swagger-codegen,代码行数:8,代码来源:TestConfiguration.cs

示例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");
 }
开发者ID:frantuma,项目名称:swagger-codegen,代码行数:9,代码来源:TestPet.cs

示例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);
        }
开发者ID:frantuma,项目名称:swagger-codegen,代码行数:9,代码来源:TestPet.cs

示例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);
        }
开发者ID:frantuma,项目名称:swagger-codegen,代码行数:10,代码来源:TestPet.cs

示例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);
            }
        }
开发者ID:DariusMR,项目名称:swagger-codegen,代码行数:12,代码来源:TestPet.cs

示例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]);
            }
        }
开发者ID:nbruno,项目名称:swagger-codegen,代码行数:12,代码来源:PetApiTests.cs

示例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);
        }
开发者ID:romerod,项目名称:swagger-codegen,代码行数:17,代码来源:TestConfiguration.cs

示例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);
        }
开发者ID:DariusMR,项目名称:swagger-codegen,代码行数:20,代码来源:TestPet.cs

示例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);
        }
开发者ID:romerod,项目名称:swagger-codegen,代码行数:21,代码来源:TestConfiguration.cs

示例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);

        }
开发者ID:ckaeslin,项目名称:swagger-codegen,代码行数:13,代码来源:PetApiTests.cs

示例14: Init

 public void Init()
 {
     instance = new PetApi();
 }
开发者ID:QualityUnit,项目名称:swagger-codegen,代码行数:4,代码来源:PetApiTests.cs

示例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);

		}
开发者ID:ckaeslin,项目名称:swagger-codegen,代码行数:26,代码来源:ApiClientTests.cs


注:本文中的IO.Swagger.Api.PetApi类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。