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


C# TimeSpan.Should方法代码示例

本文整理汇总了C#中System.TimeSpan.Should方法的典型用法代码示例。如果您正苦于以下问题:C# TimeSpan.Should方法的具体用法?C# TimeSpan.Should怎么用?C# TimeSpan.Should使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.TimeSpan的用法示例。


在下文中一共展示了TimeSpan.Should方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Should_fail_when_asserting_nullable_TimeSpan_value_with_a_value_to_be_null

        public void Should_fail_when_asserting_nullable_TimeSpan_value_with_a_value_to_be_null()
        {
            TimeSpan? nullableTimeSpan = new TimeSpan();
            Action act = () => nullableTimeSpan.Should().NotHaveValue();
            act.ShouldThrow<AssertFailedException>();

        }
开发者ID:uhaciogullari,项目名称:FluentAssertions.MonoTouch,代码行数:7,代码来源:NullableSimpleTimeSpanAssertionSpecs.cs

示例2: Should_support_chaining_constraints_with_and

 public void Should_support_chaining_constraints_with_and()
 {
     TimeSpan? nullableTimeSpan = new TimeSpan();
     nullableTimeSpan.Should()
         .HaveValue()
         .And
         .Be(new TimeSpan());
 }
开发者ID:rodolfograve,项目名称:fluentassertions,代码行数:8,代码来源:NullableSimpleTimeSpanAssertionSpecs.cs

示例3: Should_succeed_when_asserting_nullable_TimeSpan_value_with_a_value_to_have_a_value

        public void Should_succeed_when_asserting_nullable_TimeSpan_value_with_a_value_to_have_a_value()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            TimeSpan? nullableTimeSpan = new TimeSpan();

            //-------------------------------------------------------------------------------------------------------------------
            // Act / Assert
            //-------------------------------------------------------------------------------------------------------------------
            nullableTimeSpan.Should().HaveValue();
        }
开发者ID:voicu-matei,项目名称:fluentassertions,代码行数:12,代码来源:NullableSimpleTimeSpanAssertionSpecs.cs

示例4: should_be_able_to_deseralize_timespan_objects_from_floatseconds

        public void should_be_able_to_deseralize_timespan_objects_from_floatseconds()
        {
            var timespan = new TimeSpan(days: 1, hours: 2, minutes: 3, seconds: 4, milliseconds: 5);
            var input = new Datum()
                {
                    type = Datum.DatumType.R_NUM,
                    r_num = timespan.TotalSeconds
                };

            var output = DatumConvert.DeserializeObject<TimeSpan>(input, new TimeSpanConverter());
            timespan.Should().Be(output);
        }
开发者ID:jrote1,项目名称:rethinkdb-net,代码行数:12,代码来源:TimeSpanTests.cs

示例5: When_time_is_within_specified_number_of_milliseconds_from_another_value_it_should_succeed

        public void When_time_is_within_specified_number_of_milliseconds_from_another_value_it_should_succeed()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var time = new TimeSpan(1, 12, 15, 31, 035);
            var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => time.Should().BeCloseTo(nearbyTime, 35);

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldNotThrow();
        }
开发者ID:voicu-matei,项目名称:fluentassertions,代码行数:18,代码来源:SimpleTimeSpanAssertionSpecs.cs

示例6: When_time_is_greater_then_and_not_close_to_another_value_it_should_throw_with_descriptive_message

        public void When_time_is_greater_then_and_not_close_to_another_value_it_should_throw_with_descriptive_message()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var time = new TimeSpan(1, 12, 15, 31, 021);
            var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => time.Should().BeCloseTo(nearbyTime, 20, "we want to test the error message");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>()
                .WithMessage(
                    "Expected time to be within 20 ms from 1d, 12h, 15m and 31s because we want to test the error message, but found 1d, 12h, 15m and 31.021s.");
        }
开发者ID:voicu-matei,项目名称:fluentassertions,代码行数:20,代码来源:SimpleTimeSpanAssertionSpecs.cs

示例7: When_time_is_greater_then_but_close_to_another_value_it_should_succeed

        public void When_time_is_greater_then_but_close_to_another_value_it_should_succeed()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var time = new TimeSpan(1, 12, 15, 31, 020);
            var nearbyTime = new TimeSpan(1, 12, 15, 31, 000);

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => time.Should().BeCloseTo(nearbyTime);

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldNotThrow();
        }
开发者ID:voicu-matei,项目名称:fluentassertions,代码行数:18,代码来源:SimpleTimeSpanAssertionSpecs.cs

示例8: Should_succeed_when_asserting_nullable_TimeSpan_value_with_a_value_to_have_a_value

 public void Should_succeed_when_asserting_nullable_TimeSpan_value_with_a_value_to_have_a_value()
 {
     TimeSpan? nullableTimeSpan = new TimeSpan();
     nullableTimeSpan.Should().HaveValue();
 }
开发者ID:rodolfograve,项目名称:fluentassertions,代码行数:5,代码来源:NullableSimpleTimeSpanAssertionSpecs.cs

示例9: Pipeline_can_be_used_to_time_an_operation

        public async Task Pipeline_can_be_used_to_time_an_operation()
        {
            var time = new TimeSpan();
            var aggregator = Aggregator
                .Create<BalanceProjection, IDomainEvent>((projection, events) =>
                {
                    return Task.Run(() => Thread.Sleep(1000));
                })
                .Pipeline(async (projection, batch, next) =>
                {
                    var stopwatch = new Stopwatch();
                    stopwatch.Start();
                    await next(projection, batch);
                    time = stopwatch.Elapsed;
                });

            await aggregator.Aggregate(null, null);

            time.Should().BeGreaterOrEqualTo(TimeSpan.FromSeconds(1));
        }
开发者ID:gitter-badger,项目名称:Alluvial,代码行数:20,代码来源:PipelineTests.cs

示例10: Should_support_chaining_constraints_with_and

        public void Should_support_chaining_constraints_with_and()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            TimeSpan? nullableTimeSpan = new TimeSpan();

            //-------------------------------------------------------------------------------------------------------------------
            // Act / Assert
            //-------------------------------------------------------------------------------------------------------------------
            nullableTimeSpan.Should()
                .HaveValue()
                .And
                .Be(new TimeSpan());
        }
开发者ID:voicu-matei,项目名称:fluentassertions,代码行数:15,代码来源:NullableSimpleTimeSpanAssertionSpecs.cs

示例11: When_asserting_a_nullable_TimeSpan_is_equal_to_the_same_nullable_TimeSpan_it_should_succed

        public void When_asserting_a_nullable_TimeSpan_is_equal_to_the_same_nullable_TimeSpan_it_should_succed()
        {
            //-------------------------------------------------------------------------------------------------------------------
            // Arrange
            //-------------------------------------------------------------------------------------------------------------------
            TimeSpan? nullableTimeSpanA = new TimeSpan();
            TimeSpan? nullableTimeSpanB = new TimeSpan();

            //-------------------------------------------------------------------------------------------------------------------
            // Act
            //-------------------------------------------------------------------------------------------------------------------
            Action action = () => nullableTimeSpanA.Should().Be(nullableTimeSpanB);

            //-------------------------------------------------------------------------------------------------------------------
            // Assert
            //-------------------------------------------------------------------------------------------------------------------
            action.ShouldNotThrow();
        }
开发者ID:voicu-matei,项目名称:fluentassertions,代码行数:18,代码来源:NullableSimpleTimeSpanAssertionSpecs.cs


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