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


C# Cookie.Equals方法代码示例

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


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

示例1: Equals_Compare_Success

        public static void Equals_Compare_Success()
        {
            Cookie c1 = new Cookie();

            Cookie c2 = new Cookie("name", "value");
            Cookie c3 = new Cookie("Name", "value");
            Cookie c4 = new Cookie("different-name", "value");
            Cookie c5 = new Cookie("name", "different-value");

            Cookie c6 = new Cookie("name", "value", "path");
            Cookie c7 = new Cookie("name", "value", "path");
            Cookie c8 = new Cookie("name", "value", "different-path");

            Cookie c9 = new Cookie("name", "value", "path", "domain");
            Cookie c10 = new Cookie("name", "value", "path", "domain");
            Cookie c11 = new Cookie("name", "value", "path", "Domain");
            Cookie c12 = new Cookie("name", "value", "path", "different-domain");

            Cookie c13 = new Cookie("name", "value", "path", "domain") { Version = 5 };
            Cookie c14 = new Cookie("name", "value", "path", "domain") { Version = 5 };
            Cookie c15 = new Cookie("name", "value", "path", "domain") { Version = 100 };

            Assert.False(c2.Equals(null));
            Assert.False(c2.Equals(""));

            Assert.NotEqual(c1, c2);

            Assert.Equal(c2, c3);
            Assert.Equal(c3, c2);
            Assert.NotEqual(c2, c4);
            Assert.NotEqual(c2, c5);
            Assert.NotEqual(c2, c6);
            Assert.NotEqual(c2, c9);
            
            Assert.NotEqual(c2.GetHashCode(), c4.GetHashCode());
            Assert.NotEqual(c2.GetHashCode(), c5.GetHashCode());
            Assert.NotEqual(c2.GetHashCode(), c6.GetHashCode());
            Assert.NotEqual(c2.GetHashCode(), c9.GetHashCode());

            Assert.Equal(c6, c7);
            Assert.NotEqual(c6, c8);
            Assert.NotEqual(c6, c9);
            
            Assert.NotEqual(c6.GetHashCode(), c8.GetHashCode());
            Assert.NotEqual(c6.GetHashCode(), c9.GetHashCode());

            Assert.Equal(c9, c10);
            Assert.Equal(c9, c11);
            Assert.NotEqual(c9, c12);

            Assert.Equal(c9.GetHashCode(), c10.GetHashCode());
            Assert.NotEqual(c9.GetHashCode(), c12.GetHashCode());

            Assert.Equal(c13, c14);
            Assert.NotEqual(c13, c15);
            Assert.Equal(c13.GetHashCode(), c14.GetHashCode());
            Assert.NotEqual(c13.GetHashCode(), c15.GetHashCode());
        }
开发者ID:noahfalk,项目名称:corefx,代码行数:58,代码来源:CookieTest.cs


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