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


C# Pet.Equals方法代码示例

本文整理汇总了C#中IO.Swagger.Model.Pet.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Pet.Equals方法的具体用法?C# Pet.Equals怎么用?C# Pet.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IO.Swagger.Model.Pet的用法示例。


在下文中一共展示了Pet.Equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestEqual

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


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