Example #1
0
        public void TestEqual()
        {
            // create pet
            Pet p1 = new Pet();
            p1.Id = petId;
            p1.Name = "Csharp test";
            p1.Status = "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 = "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();
            p2.Id = petId;
            p2.Name = "Csharp test";
            p2.Status = "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 = "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));
        }
Example #2
0
		/// <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>
        /// Create a table category on the Asset Database. 
        /// </summary>
        /// <param name="webId">The ID of the database in which to create the table category.</param>
        /// <param name="body">The new table category definition.</param>
        /// <returns></returns>
        public async System.Threading.Tasks.Task CreateTableCategoryAsync (string webId, Category body)
        {
            // verify the required parameter 'webId' is set
            if (webId == null) throw new ApiException(400, "Missing required parameter 'webId' when calling CreateTableCategory");
            // verify the required parameter 'body' is set
            if (body == null) throw new ApiException(400, "Missing required parameter 'body' when calling CreateTableCategory");
            
    
            var path_ = "/assetdatabases/{webId}/tablecategories";
    
            var pathParams = new Dictionary<String, String>();
            var queryParams = new Dictionary<String, String>();
            var headerParams = new Dictionary<String, String>();
            var formParams = new Dictionary<String, String>();
            var fileParams = new Dictionary<String, FileParameter>();
            String postBody = null;

            // to determine the Accept header
            String[] http_header_accepts = new String[] {
                "application/json"
            };
            String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
            if (http_header_accept != null)
                headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));

            // set "format" to json by default
            // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
            pathParams.Add("format", "json");
            if (webId != null) pathParams.Add("webId", ApiClient.ParameterToString(webId)); // path parameter
            
            
            
            
            postBody = ApiClient.Serialize(body); // http body (model) parameter
            
    
            // authentication setting, if any
            String[] authSettings = new String[] {  };
    
            // make the HTTP request
            IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
            if (((int)response.StatusCode) >= 400)
                throw new ApiException ((int)response.StatusCode, "Error calling CreateTableCategory: " + response.Content, response.Content);

            
            return;
        }
Example #4
0
        /// <summary>
        /// Create a Pet object
        /// </summary>
        private Pet createPet()
        {
            // 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;

            return p;
        }
 public void Init()
 {
     instance = new Category();
 }
Example #6
-1
        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);
        }