本文整理汇总了C#中WriteConcern.With方法的典型用法代码示例。如果您正苦于以下问题:C# WriteConcern.With方法的具体用法?C# WriteConcern.With怎么用?C# WriteConcern.With使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WriteConcern
的用法示例。
在下文中一共展示了WriteConcern.With方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: With_should_return_same_instance_when_value_is_equal
public void With_should_return_same_instance_when_value_is_equal(
[Values("w", "mode", "wValue", "wTimeout", "fsync", "journal")]
string fieldName)
{
var wValue = fieldName == "mode" ? (WriteConcern.WValue)new WriteConcern.WMode("mode") : new WriteConcern.WCount(1);
var wTimeout = TimeSpan.FromSeconds(2);
var fsync = false;
var journal = true;
var subject = new WriteConcern(wValue, wTimeout, fsync, journal);
WriteConcern result;
switch (fieldName)
{
case "w": result = subject.With(w: 1); break;
case "mode": result = subject.With(mode: "mode"); break;
case "wValue": result = subject.With(w: wValue); break;
case "wTimeout": result = subject.With(wTimeout: wTimeout); break;
case "fsync": result = subject.With(fsync: fsync); break;
case "journal": result = subject.With(journal: journal); break;
default: throw new ArgumentException("providedFieldName");
}
result.Should().BeSameAs(subject);
}
示例2: With_should_return_same_instance_when_no_values_are_provided
public void With_should_return_same_instance_when_no_values_are_provided()
{
var subject = new WriteConcern();
var result = subject.With();
result.Should().BeSameAs(subject);
}
示例3: With_should_return_new_instance_when_any_value_is_not_equal
public void With_should_return_new_instance_when_any_value_is_not_equal(
[Values("w", "wTimeout", "fsync", "journal")]
string notEqualFieldName)
{
var w = (WriteConcern.WValue)1;
var wTimeout = TimeSpan.FromSeconds(2);
var fsync = false;
var journal = false;
var subject = new WriteConcern(w, wTimeout, fsync, journal);
switch (notEqualFieldName)
{
case "w": w = (WriteConcern.WValue)2; break;
case "wTimeout": wTimeout = TimeSpan.FromSeconds(3); break;
case "fsync": fsync = true; break;
case "journal": journal = true; break;
default: throw new ArgumentException("notEqualFieldName");
}
var result = subject.With(w, wTimeout, fsync, journal);
result.Should().NotBeSameAs(subject);
result.W.Should().Be(w);
result.WTimeout.Should().Be(wTimeout);
result.FSync.Should().Be(fsync);
result.Journal.Should().Be(journal);
}
示例4: With_should_return_same_instance_when_all_values_are_equal
public void With_should_return_same_instance_when_all_values_are_equal()
{
var subject = new WriteConcern(1, TimeSpan.FromSeconds(2), true, true);
var result = subject.With(1, TimeSpan.FromSeconds(2), true, true);
result.Should().BeSameAs(subject);
}
示例5: 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);
}