public void Given_two_equal_durations_When_asserting_is_less_or_equal_to_Then_the_assertion_fails(int actual, int expected) =>
 Duration.FromDays(actual).Should().BeLessOrEqualTo(Duration.FromDays(expected), because, becauseArgs);
 public void Given_a_long_and_a_short_duration_When_asserting_is_less_or_equal_to_Then_the_assertion_fails(int actual, int expected) =>
 new Action(() => Duration.FromDays(actual).Should().BeLessOrEqualTo(Duration.FromDays(expected), because, becauseArgs))
 .Should().Throw <AssertionException>().WithMessage($"Expected duration to be less than or equal to {expected}:00:00:00 because the answer should be 42, but found {actual}:00:00:00.");
 public void Given_a_short_and_a_long_duration_When_asserting_is_less_or_equal_to_Then_the_assertion_passes(int actual, int expected) =>
 Duration.FromDays(actual).Should().BeLessOrEqualTo(Duration.FromDays(expected), because, becauseArgs);
 public void Given_two_equal_durations_and_no_reason_When_asserting_is_less_or_equal_to_Then_the_assertion_fails(int actual, int expected) =>
 Duration.FromDays(actual).Should().BeLessOrEqualTo(Duration.FromDays(expected), null, null);
Пример #5
0
 /// <inheritdoc cref="Duration.FromDays(double?)"/>
 public static Duration?Days(this float?value) => Duration.FromDays(value);
        public async Task When_recruitment_form_from_latest_recruitment_campaign_is_submitted__its_summary_has_flag_IsOldSubmission_set_to_false()
        {
            // Arrange
            var oldCampaign = new Impl.Entities.Campaign(now.Minus(Duration.FromDays(30)), now.Minus(Duration.FromDays(25)), editionId: 1);

            oldCampaign.GetType().GetProperty(nameof(oldCampaign.Id)).SetValue(oldCampaign, 1);

            var newCampaign = new Impl.Entities.Campaign(now.Minus(aWeek), now.Plus(aWeek), editionId: 1);

            newCampaign.GetType().GetProperty(nameof(newCampaign.Id)).SetValue(newCampaign, 2);

            var training = new Impl.Entities.Training("Papieska 21/37", "Wadowice", now.Plus(2 * aWeek), now.Plus(2 * aWeek + anHour), Guid.NewGuid());

            training.GetType().GetProperty(nameof(training.ID)).SetValue(training, 1);
            newCampaign.ScheduleTraining(training);
            var campaignRepo = Mock.Of <ICampaignRepository>(mock =>
                                                             mock.GetById(1) == Task.FromResult(oldCampaign) &&
                                                             mock.GetById(2) == Task.FromResult(newCampaign) &&
                                                             mock.GetAll() == Task.FromResult(new[] { oldCampaign, newCampaign } as IReadOnlyCollection <Impl.Entities.Campaign>), MockBehavior.Strict);

            var repo = new EnrollmentRepoStub(new EnrollmentReadModel()
            {
                Id       = EnrollmentAggregate.EnrollmentId.New,
                Campaign = new EnrollmentReadModel.CampaignSummary()
                {
                    Id = 2
                },
                PreferredTrainings       = Array.Empty <EnrollmentReadModel.TrainingSummary>(),
                PreferredLecturingCities = Array.Empty <string>()
            });

            var queryHandler = new GetSubmissionsQueryHandler(repo, campaignRepo, clock);

            // Act
            var result = await queryHandler.Handle(new Recruitment.Enrollments.GetSubmissions.Query(), CancellationToken.None);

            // Assert
            var summary = Assert.Single(result);

            Assert.True(summary.Campaign.ID == 2);
            Assert.False(summary.IsOldSubmission);
        }
Пример #7
0
 public void Given_two_different_durations_and_no_reason_When_asserting_they_are_equal_Then_the_assertion_fails_with_the_expected_message() =>
 new Action(() => Duration.FromDays(5).Should().Be(Duration.FromDays(6), null, null))
 .Should().Throw <AssertionException>().WithMessage("Expected duration to be 6:00:00:00, but found 5:00:00:00.");
Пример #8
0
 /// <inheritdoc cref="Duration.FromDays(double?)"/>
 public static Duration?Days(this long?value) => Duration.FromDays(value);
Пример #9
0
 public void Given_two_equal_durations_When_asserting_they_are_equal_Then_the_assertion_passes() =>
 Duration.FromDays(2).Should().Be(Duration.FromDays(2), because, becauseArgs);
Пример #10
0
 public void Given_two_different_durations_When_asserting_they_are_equal_Then_the_assertion_fails_with_the_expected_message() =>
 new Action(() => Duration.FromDays(3).Should().Be(Duration.FromDays(4), because, becauseArgs))
 .Should().Throw <AssertionException>().WithMessage("Expected duration to be 4:00:00:00 because the answer should be 42, but found 3:00:00:00.");
Пример #11
0
 public void Given_two_equal_durations_and_no_reason_When_asserting_they_are_equal_Then_the_assertion_passes() =>
 Duration.FromDays(1).Should().Be(Duration.FromDays(1), null, null);
 public ChangeOfChargesTransactionBuilder WithValidityStartDateDays(int days)
 {
     _validityStartDate = SystemClock.Instance.GetCurrentInstant()
                          .Plus(Duration.FromDays(days));
     return(this);
 }
Пример #13
0
        public Task Handle(EvaluatingJavaScriptExpression notification, CancellationToken cancellationToken)
        {
            var engine = notification.Engine;

            engine.SetValue("getDateOfBirth", (Func <string, object>)(age => clock.GetCurrentInstant().Minus(Duration.FromDays(int.Parse(age) * 365)).ToDateTimeUtc().Year));
            return(Task.CompletedTask);
        }
Пример #14
0
 /// <summary>
 /// Get the duration of this rotation
 /// </summary>
 /// <returns>Duration</returns>
 public Duration GetDuration()
 {
     return(Duration.FromDays(GetPeriods().Count));
 }
Пример #15
0
 /// <inheritdoc cref="Duration.FromDays(UnitsNet.QuantityValue)" />
 public static Duration Days <T>(this T value) => Duration.FromDays(Convert.ToDouble(value));
Пример #16
0
 /// <inheritdoc cref="Duration.FromDays(double)"/>
 public static Duration Days(this int value) => Duration.FromDays(value);
Пример #17
0
 private static Instant FutureDays(int days)
 {
     return(SystemClock.Instance.GetCurrentInstant().WithoutMs().Plus(Duration.FromDays(days)));
 }
Пример #18
0
 /// <inheritdoc cref="Duration.FromDays(double?)"/>
 public static Duration?Days(this double?value) => Duration.FromDays(value);
Пример #19
0
 public void DurationIsErrorTest()
 {
     Assert.True(Duration.MaxValue.IsError());
     Assert.False(Duration.FromDays(14).IsError());
 }
Пример #20
0
 /// <inheritdoc cref="Duration.FromDays(double)"/>
 public static Duration Days(this decimal value) => Duration.FromDays(Convert.ToDouble(value));
 public void NumberToDaysTest() =>
 Assert.Equal(Duration.FromDays(2), 2.Days());