コード例 #1
0
        public void should_find_yesterday()
        {
            var currentTime = LocalTime.AtMachineTime("0300");

            LocalTime.GuessDayFromTimeOfDay(currentTime, 2100.ToTime())
            .ShouldEqual(currentTime.Add(-6.Hours()));
        }
コード例 #2
0
        public void subtract()
        {
            var firstTime  = LocalTime.AtMachineTime(DateTime.Today.AddHours(8));
            var secondTime = LocalTime.AtMachineTime(DateTime.Today.AddHours(12));

            secondTime.Subtract(firstTime).ShouldEqual(4.Hours());
        }
コード例 #3
0
        public void guess_day_should_find_tomorrow()
        {
            var currentTime = LocalTime.AtMachineTime("2300");

            LocalTime.GuessDayFromTimeOfDay(currentTime, 800.ToTime())
            .ShouldEqual(currentTime.Add(9.Hours()));
        }
コード例 #4
0
        public void GuessDayFromTimeOfDay()
        {
            var morningTime = LocalTime.AtMachineTime(DateTime.Today.AddHours(8)); // 8 in the morning

            LocalTime.GuessDayFromTimeOfDay(morningTime, "0600".ToTime()).ShouldEqual(morningTime.Add(-2.Hours()));
            LocalTime.GuessDayFromTimeOfDay(morningTime, "0900".ToTime()).ShouldEqual(morningTime.Add(1.Hours()));
            LocalTime.GuessDayFromTimeOfDay(morningTime, "1000".ToTime()).ShouldEqual(morningTime.Add(2.Hours()));
            LocalTime.GuessDayFromTimeOfDay(morningTime, "1500".ToTime()).ShouldEqual(morningTime.Add(7.Hours()));
        }
コード例 #5
0
        public void set_the_clock_with_a_local_time()
        {
            var local = LocalTime.AtMachineTime("0800");

            var clock = new SettableClock();

            clock.LocalNow(local);

            clock.LocalTime().ShouldNotBeTheSameAs(local).ShouldEqual(local);

            clock.UtcNow().ShouldEqual(local.UtcTime);
        }
コード例 #6
0
        public void dehydrate_and_hydrate()
        {
            var time = LocalTime.AtMachineTime("0800");
            var text = time.Hydrate();

            Debug.WriteLine(text);

            var time2 = new LocalTime(text);

            time2.UtcTime.ShouldEqual(time.UtcTime);

            time2.ShouldNotBeTheSameAs(time);
            time2.ShouldEqual(time);
        }
        public void SetUp()
        {
            theTime = new SettableClock();
            theTime.LocalNow(LocalTime.AtMachineTime("1200")); // doesn't matter what, only needs to be constant

            theContainer = new Container(x => {
                x.IncludeRegistry <RavenDbRegistry>();
                x.For <RavenDbSettings>().Use(new RavenDbSettings {
                    RunInMemory = true, DataDirectory = null, Url = null, ConnectionString = null
                });

                x.For <ISystemTime>().Use(theTime);
            });
        }
コード例 #8
0
        public void stub_by_using_at_local_time_by_time()
        {
            var systemTime = SystemTime.AtLocalTime("0700".ToTime());

            systemTime.LocalTime().ShouldEqual(LocalTime.AtMachineTime("0700"));
        }
コード例 #9
0
 public void hydrate_with_only_time()
 {
     new LocalTime("0800").ShouldEqual(LocalTime.AtMachineTime("0800"));
 }
コード例 #10
0
        public void beginning_of_day()
        {
            var morningTime = LocalTime.AtMachineTime(DateTime.Today.AddHours(8)); // 8 in the morning

            morningTime.BeginningOfDay().UtcTime.AddHours(8).ShouldEqual(morningTime.UtcTime);
        }
コード例 #11
0
 public void hydrate_with_only_time()
 {
     new LocalTime("0800").Time.ShouldBe(LocalTime.AtMachineTime("0800").Time);
 }