当前位置: 首页>>代码示例>>C#>>正文


C# WriteConcern.With方法代码示例

本文整理汇总了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);
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:24,代码来源:WriteConcernTests.cs

示例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);
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:8,代码来源:WriteConcernTests.cs

示例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);
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:26,代码来源:WriteConcernTests.cs

示例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);
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:8,代码来源:WriteConcernTests.cs

示例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);
        }
开发者ID:fir3pho3nixx,项目名称:mongo-csharp-driver,代码行数:24,代码来源:WriteConcernTests.cs


注:本文中的WriteConcern.With方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。