本文整理汇总了C#中Union.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Union.Equals方法的具体用法?C# Union.Equals怎么用?C# Union.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Union
的用法示例。
在下文中一共展示了Union.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DifferentT4Values_ArentEqual
public void DifferentT4Values_ArentEqual()
{
var a = new Union<int, string, Colors, Animals>(Animals.Cat);
var b = new Union<int, string, Colors, Animals>(Animals.Cow);
IsFalse(a.Equals(b));
IsFalse(a == b);
}
示例2: DifferentT3Values_ArentEqual
public void DifferentT3Values_ArentEqual()
{
var a = new Union<int, string, Colors>(Colors.Blue);
var b = new Union<int, string, Colors>(Colors.Green);
IsFalse(a.Equals(b));
IsTrue(a != b);
}
示例3: DifferentT2Values_ArentEqual
public void DifferentT2Values_ArentEqual()
{
var a = new Union<int, string, Colors>("abc");
var b = new Union<int, string, Colors>("def");
IsFalse(a.Equals(b));
IsTrue(a != b);
}
示例4: ComparingT2ValueWithNull_ResultsInNotEqual
public void ComparingT2ValueWithNull_ResultsInNotEqual()
{
var a = new Union<int, string>(null);
IsFalse(a.Equals(null));
IsTrue(a != null);
IsTrue(null != a);
}
示例5: DifferentT2Values_ArentEqual
public void DifferentT2Values_ArentEqual()
{
var a = new Union<int, string>("a");
var b = new Union<int, string>("b");
IsFalse(a.Equals(b));
IsTrue(a != b);
}
示例6: DifferentT3Values_ArentEqual
public void DifferentT3Values_ArentEqual()
{
var a = new Union<int, string, Colors, Animals>(Colors.Blue);
var b = new Union<int, string, Colors, Animals>(Colors.Red);
IsFalse(a.Equals(b));
IsFalse(a == b);
}
示例7: DifferentT1T3Values_AreNotEqualAndHaveDifferentHashCodes
public void DifferentT1T3Values_AreNotEqualAndHaveDifferentHashCodes()
{
var a = new Union<int, string, Colors>(0);
var b = new Union<int, string, Colors>(Colors.Green);
IsFalse(a.Equals(b));
IsTrue(a != b);
AreNotEqual(a.GetHashCode(), b.GetHashCode());
}
示例8: SameT3Values_AreEqualAndHaveSameHashCode
public void SameT3Values_AreEqualAndHaveSameHashCode()
{
var a = new Union<int, string, Colors>(Colors.Blue);
var b = new Union<int, string, Colors>(Colors.Blue);
IsTrue(a.Equals(b));
IsTrue(a == b);
AreEqual(a.GetHashCode(), b.GetHashCode());
}
示例9: DifferentValues_AreNotEqualAndHaveDifferentHashCodes
public void DifferentValues_AreNotEqualAndHaveDifferentHashCodes()
{
var a = new Union<int, string>(0);
var b = new Union<int, string>("1234");
IsFalse(a.Equals(b));
IsTrue(a != b);
AreNotEqual(a.GetHashCode(), b.GetHashCode());
}
示例10: SameT2Values_AreEqualAndHaveSameHashCode
public void SameT2Values_AreEqualAndHaveSameHashCode()
{
var a = new Union<int, string>("1234");
var b = new Union<int, string>("1234");
IsTrue(a.Equals(b));
IsTrue(a == b);
AreEqual(a.GetHashCode(), b.GetHashCode());
}
示例11: SameT4Values_AreEqualAndHaveSameHashCode
public void SameT4Values_AreEqualAndHaveSameHashCode()
{
var a = new Union<int, string, Colors, Animals>(Animals.Cat);
var b = new Union<int, string, Colors, Animals>(Animals.Cat);
IsTrue(a.Equals(b));
IsTrue(a == b);
AreEqual(a.GetHashCode(), b.GetHashCode());
}
示例12: UnionIsNotEqualToStructurallyInequalUnion
public void UnionIsNotEqualToStructurallyInequalUnion()
{
Union<Item, DataUnit> union1 = new Union<Item, DataUnit>.Case1(new Item(42));
Union<Item, DataUnit> union2 = new Union<Item, DataUnit>.Case2(new DataUnit(42));
Assert.False(union1.Equals(union2));
Assert.False(union2.Equals(union1));
Assert.True(union1 != union2);
Assert.True(union2 != union1);
}
示例13: UnionEqualsSameUnion
public void UnionEqualsSameUnion()
{
Union<Item, DataUnit> union1 = new Union<Item, DataUnit>.Case1(new Item(42));
Union<Item, DataUnit> union2 = new Union<Item, DataUnit>.Case1(new Item(42));
Assert.True(union1.Equals(union2));
Assert.True(union2.Equals(union1));
Assert.True(union1 == union2);
Assert.True(union2 == union1);
}
示例14: UnionEqualsItself
public void UnionEqualsItself()
{
Union<Item, DataUnit> union = new Union<Item, DataUnit>.Case1(new Item(42));
Assert.True(union.Equals(union));
}
示例15: ComparingT4ValueWithNull_ResultsInNotEqual
public void ComparingT4ValueWithNull_ResultsInNotEqual()
{
var a = new Union<int, string, Colors, Animals>(Animals.Dog);
IsFalse(a.Equals(null));
IsTrue(a != null);
IsTrue(null != a);
}