本文整理汇总了C#中WriteConcern.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# WriteConcern.GetHashCode方法的具体用法?C# WriteConcern.GetHashCode怎么用?C# WriteConcern.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WriteConcern
的用法示例。
在下文中一共展示了WriteConcern.GetHashCode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Equals_should_return_false_if_wTimeout_is_not_equal
public void Equals_should_return_false_if_wTimeout_is_not_equal(int? wTimeout1Seconds, int? wTimeout2Seconds)
{
var wTimeout1 = wTimeout1Seconds.HasValue ? (TimeSpan?)TimeSpan.FromSeconds(wTimeout1Seconds.Value) : null;
var wTimeout2 = wTimeout2Seconds.HasValue ? (TimeSpan?)TimeSpan.FromSeconds(wTimeout2Seconds.Value) : null;
var writeConcern1 = new WriteConcern(null, wTimeout1, null, null);
var writeConcern2 = new WriteConcern(null, wTimeout2, null, null);
writeConcern1.Equals((WriteConcern)writeConcern2).Should().BeFalse();
writeConcern1.Equals((object)writeConcern2).Should().BeFalse();
writeConcern1.GetHashCode().Should().NotBe(writeConcern2.GetHashCode());
}
示例2: Equals_should_return_true_if_all_fields_are_equal
public void Equals_should_return_true_if_all_fields_are_equal(int? w, int? wTimeoutSeconds, bool? fsync, bool? journal)
{
var wCount = w.HasValue ? (WriteConcern.WValue)w.Value : null;
var wTimeout = wTimeoutSeconds.HasValue ? (TimeSpan?)TimeSpan.FromSeconds(wTimeoutSeconds.Value) : null;
var writeConcern1 = new WriteConcern(wCount, wTimeout, fsync, journal);
var writeConcern2 = new WriteConcern(wCount, wTimeout, fsync, journal);
writeConcern1.Equals((WriteConcern)writeConcern2).Should().BeTrue();
writeConcern1.Equals((object)writeConcern2).Should().BeTrue();
writeConcern1.GetHashCode().Should().Be(writeConcern2.GetHashCode());
}
示例3: Equals_should_return_false_if_w_is_not_equal
public void Equals_should_return_false_if_w_is_not_equal(int? w1, int? w2)
{
var wCount1 = w1.HasValue ? (WriteConcern.WValue)w1.Value : null;
var wCount2 = w2.HasValue ? (WriteConcern.WValue)w2.Value : null;
var writeConcern1 = new WriteConcern(wCount1, null, null, null);
var writeConcern2 = new WriteConcern(wCount2, null, null, null);
writeConcern1.Equals((WriteConcern)writeConcern2).Should().BeFalse();
writeConcern1.Equals((object)writeConcern2).Should().BeFalse();
writeConcern1.GetHashCode().Should().NotBe(writeConcern2.GetHashCode());
}
示例4: Equals_should_return_false_if_journal_is_not_equal
public void Equals_should_return_false_if_journal_is_not_equal(bool? journal1, bool? journal2)
{
var writeConcern1 = new WriteConcern(null, null, null, journal1);
var writeConcern2 = new WriteConcern(null, null, null, journal2);
writeConcern1.Equals((WriteConcern)writeConcern2).Should().BeFalse();
writeConcern1.Equals((object)writeConcern2).Should().BeFalse();
writeConcern1.GetHashCode().Should().NotBe(writeConcern2.GetHashCode());
}
示例5: Equals_should_return_false_if_fsync_is_not_equal
public void Equals_should_return_false_if_fsync_is_not_equal(bool? fsync1, bool? fsync2)
{
var writeConcern1 = new WriteConcern(null, null, fsync1, null);
var writeConcern2 = new WriteConcern(null, null, fsync2, null);
writeConcern1.Equals((WriteConcern)writeConcern2).Should().BeFalse();
writeConcern1.Equals((object)writeConcern2).Should().BeFalse();
writeConcern1.GetHashCode().Should().NotBe(writeConcern2.GetHashCode());
}
示例6: Equals_should_return_true_when_all_fields_are_equal
public void Equals_should_return_true_when_all_fields_are_equal()
{
var subject1 = new WriteConcern(1, TimeSpan.FromSeconds(1), false, false);
var subject2 = new WriteConcern(1, TimeSpan.FromSeconds(1), false, false);
var result1 = subject1.Equals(subject2);
var result2 = subject1.Equals((object)subject2);
var hashCode1 = subject1.GetHashCode();
var hashCode2 = subject2.GetHashCode();
result1.Should().BeTrue();
result2.Should().BeTrue();
hashCode1.Should().Be(hashCode2);
}
示例7: Equals_should_return_false_when_any_fields_are_not_equal
public void Equals_should_return_false_when_any_fields_are_not_equal(
[Values("fsync", "journal", "w", "wTimeout")]
string notEqualFieldName)
{
var subject1 = new WriteConcern(1, TimeSpan.FromSeconds(1), false, false);
WriteConcern subject2;
switch (notEqualFieldName)
{
case "fsync": subject2 = subject1.With(fsync: true); break;
case "journal": subject2 = subject1.With(journal: true); break;
case "w": subject2 = subject1.With(w: 2); break;
case "wTimeout": subject2 = subject1.With(wTimeout: TimeSpan.FromSeconds(2)); break;
default: throw new ArgumentException("notEqualFieldName");
}
var result1 = subject1.Equals(subject2);
var result2 = subject1.Equals((object)subject2);
var hashCode1 = subject1.GetHashCode();
var hashCode2 = subject2.GetHashCode();
result1.Should().BeFalse();
result2.Should().BeFalse();
hashCode1.Should().NotBe(hashCode2);
}