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


C# Duration.GetHashCode方法代码示例

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


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

示例1: TestDurationClass

        public void TestDurationClass()
        {
            var firstDuration = new Duration(200, TimeUnit.Minutes);
            
            Check.That(firstDuration.RawDuration).IsEqualTo(200);
            Check.That(firstDuration.Unit).IsEqualTo(TimeUnit.Minutes);
            Check.That(firstDuration.ToString()).IsEqualTo("200 Minutes");
            Check.That(firstDuration > new Duration(100, TimeUnit.Seconds)).IsTrue();
            Check.That(firstDuration < new Duration(100, TimeUnit.Hours)).IsTrue();

            var anotherDurationWithSameValue = new Duration(200, TimeUnit.Minutes);

            // test objects override
            Check.That(firstDuration.GetHashCode()).IsEqualTo(anotherDurationWithSameValue.GetHashCode());
            Check.That(firstDuration).IsEqualTo(anotherDurationWithSameValue);
            Check.That(anotherDurationWithSameValue.Equals(firstDuration)).IsTrue();
            Check.That(anotherDurationWithSameValue == firstDuration).IsTrue();
            Check.That(anotherDurationWithSameValue.Equals(null)).IsFalse();
            Check.That(anotherDurationWithSameValue.Equals(20)).IsFalse();
            Check.That(anotherDurationWithSameValue.Equals((object)firstDuration)).IsTrue();
        }
开发者ID:dirkrombauts,项目名称:NFluent,代码行数:21,代码来源:DurationTests.cs

示例2: TestDurationClass

        public void TestDurationClass()
        {
            var test = new Duration(200, TimeUnit.Minutes);

            Assert.AreEqual(200, test.RawDuration);

            Assert.AreEqual(TimeUnit.Minutes, test.Unit);

            Assert.AreEqual("200 Minutes", test.ToString());

            Assert.IsTrue(test > new Duration(100, TimeUnit.Seconds));
            Assert.IsTrue(test < new Duration(100, TimeUnit.Hours));

            var altDuration = new Duration(200, TimeUnit.Minutes);

            // test objects override
            Assert.AreEqual(altDuration.GetHashCode(), test.GetHashCode());
            Assert.AreEqual(altDuration, test);
            Assert.IsTrue(altDuration.Equals(test));
            Assert.IsTrue(altDuration == test);
            Assert.IsFalse(altDuration.Equals(null));
            Assert.IsFalse(altDuration.Equals(20));
            Assert.IsTrue(altDuration.Equals((object)test));
        }
开发者ID:rhwy,项目名称:NFluent,代码行数:24,代码来源:TimeHelperTest.cs


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