Exemple #1
0
        public void NoonIsInTheRightFormat()
        {
            var clock = new ClockIn12H(12, 0, 0);

            clock.Invariant.Should().BeTrue();
            clock.Hour.Should().Be(12);
            clock.Minute.Should().Be(0);
            clock.Second.Should().Be(0);
            clock.DayPeriod.Should().Be(DayPeriod.PM);
        }
Exemple #2
0
        public void AddMinutesTurnsMorningToAfternoon()
        {
            var clock = new ClockIn12H(9, 0, 0);

            clock.Invariant.Should().BeTrue();
            clock.Hour.Should().Be(9);
            clock.Minute.Should().Be(0);
            clock.Second.Should().Be(0);
            clock.DayPeriod.Should().Be(DayPeriod.AM);

            clock.AddMinutes(600);

            clock.Invariant.Should().BeTrue();
            clock.Hour.Should().Be(7);
            clock.Minute.Should().Be(0);
            clock.Second.Should().Be(0);
            clock.DayPeriod.Should().Be(DayPeriod.PM);
        }
Exemple #3
0
        public void AddHoursTurnsAfternoonToMorning()
        {
            var clock = new ClockIn12H(14, 0, 0);

            clock.Invariant.Should().BeTrue();
            clock.Hour.Should().Be(2);
            clock.Minute.Should().Be(0);
            clock.Second.Should().Be(0);
            clock.DayPeriod.Should().Be(DayPeriod.PM);

            clock.AddHours(-4);

            clock.Invariant.Should().BeTrue();
            clock.Hour.Should().Be(10);
            clock.Minute.Should().Be(0);
            clock.Second.Should().Be(0);
            clock.DayPeriod.Should().Be(DayPeriod.AM);
        }
Exemple #4
0
        public void AddSecondsTurnsMorningToAfternoon()
        {
            var clock = new ClockIn12H(9, 30, 0);

            clock.Invariant.Should().BeTrue();
            clock.Hour.Should().Be(9);
            clock.Minute.Should().Be(30);
            clock.Second.Should().Be(0);
            clock.DayPeriod.Should().Be(DayPeriod.AM);

            clock.AddSeconds(12345);

            clock.Invariant.Should().BeTrue();
            clock.Hour.Should().Be(12);
            clock.Minute.Should().Be(55);
            clock.Second.Should().Be(45);
            clock.DayPeriod.Should().Be(DayPeriod.PM);
        }
Exemple #5
0
        public void InvariantIsTrueOnEmptyCtor()
        {
            var clock = new ClockIn12H();

            clock.Invariant.Should().BeTrue();
        }