本文整理汇总了C#中Time.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Time.Equals方法的具体用法?C# Time.Equals怎么用?C# Time.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Time
的用法示例。
在下文中一共展示了Time.Equals方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Can_Compare_Time
public void Can_Compare_Time()
{
Time t1 = new Time(23,30);
Time t2 = new Time(23,30);
Time t3 = new Time(12,00);
Assert.IsTrue(t1.Equals(t2));
Assert.IsFalse(t1.Equals(t3));
Assert.IsTrue(t1 > t3);
Assert.IsTrue(t3 < t1);
Assert.IsFalse(t1 > t2);
Assert.IsTrue(t1 >= t2);
Assert.IsTrue(t2 >= t1);
}
示例2: OpEquals
public void OpEquals()
{
var time1 = new Time(3600, TimeUnit.Second);
var time2 = new Time(1, TimeUnit.Hours);
var time3 = new Time(120, TimeUnit.Minutes);
(time1 == time2).ShouldBeTrue();
(time2 == time1).ShouldBeTrue();
(time1 == time3).ShouldBeFalse();
(time3 == time1).ShouldBeFalse();
time1.Equals(time2)
.ShouldBeTrue();
time1.Equals((object)time2)
.ShouldBeTrue();
time2.Equals(time1)
.ShouldBeTrue();
time2.Equals((object)time1)
.ShouldBeTrue();
}
示例3: Times_With_The_Same_Time_Should_Be_Equal
public void Times_With_The_Same_Time_Should_Be_Equal()
{
var time1 = new Time(1, 30);
var time2 = new Time(1, 30);
Assert.Equal(time1, time2);
Assert.True(time1 == time2);
Assert.False(time1 != time2);
Assert.True(time1.Equals(time2));
}
示例4: Times_With_Another_Time_Should_Not_Be_Equal
public void Times_With_Another_Time_Should_Not_Be_Equal()
{
var time1 = new Time(1, 30);
var time2 = new Time(1, 31);
var time3 = new Time(2, 30);
Assert.NotEqual(time1, time2);
Assert.NotEqual(time1, time3);
Assert.False(time1 == time2);
Assert.True(time1 != time2);
Assert.False(time1.Equals(time2));
}
示例5: EqualsObjectTest
public void EqualsObjectTest()
{
Time target = new Time(10F);
object obj = new Time(10F);
bool expected = true;
bool actual;
actual = target.Equals(obj);
Assert.AreEqual(expected, actual);
}
示例6: EqualsTimeSpanTest
public void EqualsTimeSpanTest()
{
Time target = new Time(10F);
TimeSpan obj = new TimeSpan(0, 0, 10);
bool expected = true;
bool actual;
actual = target.Equals(obj);
Assert.AreEqual(expected, actual);
}
示例7: EqualsDoubleTest
public void EqualsDoubleTest()
{
Time target = new Time(10F);
double obj = 10F;
bool expected = true;
bool actual;
actual = target.Equals(obj);
Assert.AreEqual(expected, actual);
}
示例8: DateTimeInterop
public void DateTimeInterop()
{
Time t1 = new Time(2000, 1, 2, 3, 4, 5, 6);
DateTime t2 = new DateTime(2003, 9, 1, 13, 44, 55, 6);
DateTime t3 = new DateTime(2000, 1, 2, 3, 4, 5, 6);
t1.Equals(t2).Should().Be.False();
t2.Equals(t1).Should().Be.False();
(t1 == t2).Should().Be.False();
(t2 == t1).Should().Be.False();
(t1 != t2).Should().Be.True();
(t2 != t1).Should().Be.True();
t1.Equals(t3).Should().Be.True();
t3.Equals(t1).Should().Be.True();
(t1 == t3).Should().Be.True();
(t3 == t1).Should().Be.True();
(t1 != t3).Should().Be.False();
(t3 != t1).Should().Be.False();
}