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


C# DateTimeOffset.Should方法代码示例

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


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

示例1: When_asserting_subject_datetimeoffset_should_not_have_offset_with_different_value_it_should_succeed

        public void When_asserting_subject_datetimeoffset_should_not_have_offset_with_different_value_it_should_succeed()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            DateTimeOffset subject = new DateTimeOffset(new DateTime(2009, 12, 31, 23, 59, 00), TimeSpan.Zero);
            TimeSpan expectation = TimeSpan.FromHours(3);

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.Should().NotHaveOffset(expectation);

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

示例2: DateTimeOffset

        public override async Task Immediately_scheduled_commands_triggered_by_a_scheduled_command_have_their_due_time_set_to_the_causative_command_clock()
        {
            // arrange
            var deliveredTime = new DateTimeOffset();
            var target = new CommandTarget(Any.CamelCaseName());
            await store.Put(target);
            var clockRepository = Configuration.Current.SchedulerClockRepository();
            var schedulerClockTime = DateTimeOffset.Parse("2016-02-13 01:00:00 AM");
            clockRepository.CreateClock(clockName, schedulerClockTime);
            Configuration.Current.UseCommandHandler<CommandTarget, TestCommand>(async (_, __) =>
            {
                if (__.ETag == "first")
                {
                    await Configuration.Current.CommandScheduler<CommandTarget>().Schedule(target.Id, new TestCommand
                    {
                          CanBeDeliveredDuringScheduling = true
                    });
                }
                else
                {
                    deliveredTime = Clock.Now();
                }
            });

            // act
            await scheduler.Schedule(target.Id,
                                     new TestCommand
                                     {
                                         CanBeDeliveredDuringScheduling = true,
                                         ETag = "first"
                                     },
                                     dueTime: DateTimeOffset.Parse("2016-02-13 01:05:00 AM"));

            await Configuration.Current
                               .SchedulerClockTrigger()
                               .AdvanceClock(clockName, by: 1.Hours());

            // assert 
            deliveredTime.Should().Be(DateTimeOffset.Parse("2016-02-13 01:05:00 AM"));
        }
开发者ID:charlesmccarthyirl,项目名称:Its.Cqrs,代码行数:40,代码来源:SqlCommandSchedulerTests_NonEventSourced.cs

示例3: When_asserting_a_DateTime_against_a_DateTimeOffset_it_should_validate_against_world_time

        public void When_asserting_a_DateTime_against_a_DateTimeOffset_it_should_validate_against_world_time()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var todayDateTimeOffset = new DateTimeOffset(Today);

            //-----------------------------------------------------------------------------------------------------------
            // Act / Assert
            //-----------------------------------------------------------------------------------------------------------
            todayDateTimeOffset.Should().Be(Today);
        }
开发者ID:9swampy,项目名称:fluentassertions,代码行数:12,代码来源:DateTimeAssertionSpecs.cs

示例4: When_asserting_different_date_time_offsets_representing_the_same_world_time_it_should_succeded

            When_asserting_different_date_time_offsets_representing_the_same_world_time_it_should_succeded()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var specificDate = 1.May(2008).At(6, 32);
             
            var dateWithFiveHourOffset = new DateTimeOffset(specificDate.Add(-5.Hours()), -5.Hours());

            var dateWithSixHourOffset = new DateTimeOffset(specificDate.Add(-6.Hours()), -6.Hours());

            //-----------------------------------------------------------------------------------------------------------
            // Act / Assert
            //-----------------------------------------------------------------------------------------------------------
            dateWithFiveHourOffset.Should().Be(dateWithSixHourOffset);
        }
开发者ID:leijiancd,项目名称:fluentassertions,代码行数:16,代码来源:DateTimeOffsetAssertionSpecs.cs

示例5: Should_fail_when_asserting_datetime_value_is_equal_to_the_different_value

        public void Should_fail_when_asserting_datetime_value_is_equal_to_the_different_value()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var dateTime = new DateTimeOffset(10.March(2012), 1.Hours());
            var otherDateTime = new DateTimeOffset(11.March(2012), 1.Hours());

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => dateTime.Should().Be(otherDateTime, "because we want to test the failure {0}", "message");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>()
                .WithMessage(
                    "Expected date and time to be <2012-03-11 +1h>*failure message, but found <2012-03-10 +1h>.");
        }
开发者ID:AlexanderSher,项目名称:fluentassertions,代码行数:20,代码来源:DateTimeOffsetAssertionSpecs.cs

示例6: When_asserting_subject_datetimeoffset_is_after_later_expected_datetimeoffset_should_throw

        public void When_asserting_subject_datetimeoffset_is_after_later_expected_datetimeoffset_should_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            DateTimeOffset subject = new DateTimeOffset(new DateTime(2016, 06, 04), TimeSpan.Zero);
            DateTimeOffset expectation = new DateTimeOffset(new DateTime(2016, 06, 05), TimeSpan.Zero);

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.Should().BeAfter(expectation);

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>().WithMessage("Expected a date and time after <2016-06-05>, but found <2016-06-04>.");
        }
开发者ID:somewhatabstract,项目名称:fluentassertions,代码行数:18,代码来源:DateTimeOffsetAssertionSpecs.cs

示例7: When_asserting_different_DateTimeOffsets_representing_different_world_times_it_should_not_succeded

            When_asserting_different_DateTimeOffsets_representing_different_world_times_it_should_not_succeded()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var specificDate = new DateTime(2008, 5, 1, 06, 32, 00);

            var dateWithFiveHourOffset = new DateTimeOffset(specificDate);
            var dateWithSixHourOffset = new DateTimeOffset(specificDate, 1.Hours());

            //-----------------------------------------------------------------------------------------------------------
            // Act / Assert
            //-----------------------------------------------------------------------------------------------------------
            dateWithFiveHourOffset.Should().NotBe(dateWithSixHourOffset);
        }
开发者ID:lothrop,项目名称:fluentassertions,代码行数:15,代码来源:DateTimeAssertionSpecs.cs

示例8: When_a_value_is_not_one_of_the_specified_values_it_should_throw

        public void When_a_value_is_not_one_of_the_specified_values_it_should_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var value = new DateTimeOffset(31.December(2016), 1.Hours());
            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () => value.Should().BeOneOf(value.AddDays(1), value.AddHours(4));

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action.ShouldThrow<AssertFailedException>()
                .WithMessage("Expected value to be one of {<2017-01-01 +1h>, <2016-12-31 04:00:00 +1h>}, but found <2016-12-31 +1h>.");
        }
开发者ID:somewhatabstract,项目名称:fluentassertions,代码行数:17,代码来源:DateTimeOffsetAssertionSpecs.cs

示例9: When_a_value_is_not_one_of_the_specified_values_it_should_throw_with_descriptive_message

        public void When_a_value_is_not_one_of_the_specified_values_it_should_throw_with_descriptive_message()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            DateTimeOffset value = new DateTimeOffset(31.December(2016), 1.Hours());

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () => value.Should().BeOneOf(new[] { value.AddDays(1), value.AddMonths(1) }, "because it's true");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            action.ShouldThrow<AssertFailedException>()
                .WithMessage("Expected value to be one of {<2017-01-01 +1h>, <2017-01-31 +1h>} because it's true, but found <2016-12-31 +1h>.");
        }
开发者ID:somewhatabstract,项目名称:fluentassertions,代码行数:18,代码来源:DateTimeOffsetAssertionSpecs.cs

示例10: When_asserting_subject_datetimeoffset_should_have_same_date_as_another_but_it_doesnt_it_should_throw

        public void When_asserting_subject_datetimeoffset_should_have_same_date_as_another_but_it_doesnt_it_should_throw()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            DateTimeOffset subject = new DateTimeOffset(new DateTime(2009, 12, 31), TimeSpan.Zero);
            DateTimeOffset expectation = new DateTimeOffset(new DateTime(2009, 12, 30), TimeSpan.Zero);

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.Should().BeSameDateAs(expectation);

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>().WithMessage(
                "Expected a date and time with date <2009-12-30>, but found <2009-12-31>.");
        }
开发者ID:somewhatabstract,项目名称:fluentassertions,代码行数:19,代码来源:DateTimeOffsetAssertionSpecs.cs

示例11: DateTimeOffset

        public void When_asserting_subject_datetimeoffset_should_not_have_same_date_as_another_but_it_doesnt_it_should_succeed()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            DateTimeOffset subject = new DateTimeOffset(new DateTime(2009, 12, 31), TimeSpan.Zero);
            DateTimeOffset expectation = new DateTimeOffset(new DateTime(2009, 12, 30), TimeSpan.Zero);

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.Should().NotBeSameDateAs(expectation);

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

示例12: Should_fail_when_asserting_datetimeoffset_value_is_not_equal_to_the_same_value

        public void Should_fail_when_asserting_datetimeoffset_value_is_not_equal_to_the_same_value()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            var dateTime = new DateTimeOffset(10.March(2012), 1.Hours());
            var sameDateTime = new DateTimeOffset(10.March(2012), 1.Hours());

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act =
                () => dateTime.Should().NotBe(sameDateTime, "because we want to test the failure {0}", "message");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            act.ShouldThrow<AssertFailedException>()
                .WithMessage("Expected date and time not to be <2012-03-10 +1h> because we want to test the failure message, but it is.");
        }
开发者ID:somewhatabstract,项目名称:fluentassertions,代码行数:20,代码来源:DateTimeOffsetAssertionSpecs.cs

示例13: When_a_value_is_one_of_the_specified_values_it_should_succeed

        public void When_a_value_is_one_of_the_specified_values_it_should_succeed()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            DateTimeOffset value = new DateTimeOffset(2016, 12, 30, 23, 58, 57, TimeSpan.FromHours(4));

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action action = () => value.Should().BeOneOf(new DateTimeOffset(2216, 1, 30, 0, 5, 7, TimeSpan.FromHours(2)), new DateTimeOffset(2016, 12, 30, 23, 58, 57, TimeSpan.FromHours(4)));

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

示例14: When_asserting_subject_datetimeoffset_is_close_to_an_earlier_datetimeoffset_it_should_succeed

        public void When_asserting_subject_datetimeoffset_is_close_to_an_earlier_datetimeoffset_it_should_succeed()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            DateTimeOffset time = new DateTimeOffset(2016, 06, 04, 12, 15, 31, 020, TimeSpan.Zero);
            DateTimeOffset nearbyTime = new DateTimeOffset(2016, 06, 04, 12, 15, 31, 0, TimeSpan.Zero);

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

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

示例15: When_asserting_subject_datetimeoffset_is_not_after_later_expected_datetimeoffset_should_succeed

        public void When_asserting_subject_datetimeoffset_is_not_after_later_expected_datetimeoffset_should_succeed()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            DateTimeOffset subject = new DateTimeOffset(new DateTime(2016, 06, 04), TimeSpan.Zero);
            DateTimeOffset expectation = new DateTimeOffset(new DateTime(2016, 06, 05), TimeSpan.Zero);

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            Action act = () => subject.Should().NotBeAfter(expectation);

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


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