コード例 #1
0
        public void DefaultStrategy_DaysAgo()
        {
            Configurator.DateOnlyHumanizeStrategy = new DefaultDateOnlyHumanizeStrategy();

            var inputTime = new DateOnly(2015, 07, 02);
            var baseTime  = new DateOnly(2015, 07, 05);

            const string expectedResult = "3 days ago";
            var          actualResult   = inputTime.Humanize(baseTime);

            Assert.Equal(expectedResult, actualResult);
        }
コード例 #2
0
        public void PrecisionStrategy_NextDay()
        {
            Configurator.DateOnlyHumanizeStrategy = new PrecisionDateOnlyHumanizeStrategy(0.75);

            var inputTime = new DateOnly(2015, 07, 05);
            var baseTime  = new DateOnly(2015, 07, 04);

            const string expectedResult = "tomorrow";
            var          actualResult   = inputTime.Humanize(baseTime);

            Assert.Equal(expectedResult, actualResult);
        }
コード例 #3
0
        public void DefaultStrategy_MonthApart()
        {
            Configurator.DateOnlyHumanizeStrategy = new DefaultDateOnlyHumanizeStrategy();

            var inputTime = new DateOnly(2015, 08, 05);
            var baseTime  = new DateOnly(2015, 07, 05);

            const string expectedResult = "one month from now";
            var          actualResult   = inputTime.Humanize(baseTime);

            Assert.Equal(expectedResult, actualResult);
        }
コード例 #4
0
        public void Nullable_ExpectSame()
        {
            DateOnly?never = new DateOnly(2015, 12, 7);

            Assert.Equal(never.Value.Humanize(), never.Humanize());
        }