本文整理汇总了C#中Record.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# Record.Equals方法的具体用法?C# Record.Equals怎么用?C# Record.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Record
的用法示例。
在下文中一共展示了Record.Equals方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestEquals
public void TestEquals()
{
DateTime date = new DateTime(); // TODO: 初始化為適當值
Category category = new Category(CATEGORY_NAME_WORK); // TODO: 初始化為適當值
int amount = 0; // TODO: 初始化為適當值
Record record = new Record(date, category, amount); // TODO: 初始化為適當值
object obj = new Record(date, category, amount); // TODO: 初始化為適當值
Assert.IsTrue(record.Equals(obj));
}
示例2: AssertNotEquals
/// <summary>
/// Helper method to check whether records are not equal.
/// </summary>
/// <param name="record1">First record.</param>
/// <param name="record2">Second record.</param>
private void AssertNotEquals(Record record1, Record record2)
{
Assert.IsFalse(record1.Equals(record2));
if (record2 != null)
{
Assert.IsFalse(record2.Equals(record1));
}
}
示例3: TestEqualsByRecord
public void TestEqualsByRecord()
{
DateTime date = DateTime.Now; // TODO: 初始化為適當值
Category category = new Category(CATEGORY_NAME_WORK); // TODO: 初始化為適當值
int amount = 0; // TODO: 初始化為適當值
Record record1 = new Record(date, category, amount); // TODO: 初始化為適當值
Record record2 = new Record(date, category, amount); // TODO: 初始化為適當值
Record record3 = new Record(date, category, 2222); // TODO: 初始化為適當值
Assert.IsTrue(record1.Equals(record2));
Assert.IsTrue(record1.Equals(record1));
Assert.IsFalse(record1.Equals(record3));
Assert.IsFalse(record1.Equals(null));
}
示例4: AssertEquals
/// <summary>
/// Helper method to check whether records
/// and their hash codes are equal.
/// </summary>
/// <param name="record1">First record.</param>
/// <param name="record2">Second record.</param>
private void AssertEquals(Record record1, Record record2)
{
Assert.IsTrue(record1.Equals(record2));
Assert.IsTrue(record2.Equals(record1));
Assert.AreEqual(record1.GetHashCode(), record2.GetHashCode());
}