public void GetHour_Returns_Twelve()
 {
     TimeWords expected = new TimeWords();
     expected.Twelve = true;
     var actual = RunGetHourTest(new TimeSpan(12, 2, 3));
     Assert.AreEqual(expected, actual);
 }
示例#2
0
        public static TimeWords operator +(TimeWords c1, TimeWords c2)
        {
            var value = new TimeWords();

            value.Half       = c1.Half || c2.Half;
            value.TenMinute  = c1.TenMinute || c2.TenMinute;
            value.Quarter    = c1.Quarter || c2.Quarter;
            value.Twenty     = c1.Twenty || c2.Twenty;
            value.FiveMinute = c1.FiveMinute || c2.FiveMinute;
            value.Minutes    = c1.Minutes || c2.Minutes;
            value.To         = c1.To || c2.To;
            value.Past       = c1.Past || c2.Past;
            value.One        = c1.One || c2.One;
            value.Two        = c1.Two || c2.Two;
            value.Three      = c1.Three || c2.Three;
            value.Four       = c1.Four || c2.Four;
            value.Five       = c1.Five || c2.Five;
            value.Six        = c1.Six || c2.Six;
            value.Seven      = c1.Seven || c2.Seven;
            value.Eight      = c1.Eight || c2.Eight;
            value.Nine       = c1.Nine || c2.Nine;
            value.Ten        = c1.Ten || c2.Ten;
            value.Eleven     = c1.Eleven || c2.Eleven;
            value.Twelve     = c1.Twelve || c2.Twelve;
            value.OClock     = c1.OClock || c2.OClock;

            return(value);
        }
 public void GetHour_Returns_Eleven_At_Twenty_Three()
 {
     TimeWords expected = new TimeWords();
     expected.Eleven = true;
     var actual = RunGetHourTest(new TimeSpan(23, 2, 3));
     Assert.AreEqual(expected, actual);
 }
 public void GetHour_Does_Not_Return_Twelve_at_One()
 {
     TimeWords expected = new TimeWords();
     expected.Twelve = true;
     var actual = RunGetHourTest(new TimeSpan(1, 2, 3));
     Assert.AreNotEqual(expected, actual);
 }
示例#5
0
 public void Calls_GetHour_To_Round_Minute()
 {
     var Time = new TimeSpan(1, 35, 0);//01:35:00
     var words = new TimeWords();
     words.One = true; words.Half = true; words.Past = true;
     mockFancyClockFormatter.Setup(x => x.GetMinute(Time)).Returns(words);
     var Expected = words;
     var clock = new FancyClock(mockFancyClockFormatter.Object);
     clock.Time = Time;
     var Actual = clock.Minute;
     Assert.AreEqual(Expected, Actual);
 }
示例#6
0
        public virtual TimeWords GetTime(TimeSpan Time)
        {
            TimeWords Hour = new TimeWords();

            Hour = GetHour(Time);
            TimeWords Minute = new TimeWords();

            Minute = GetMinute(Time);

            if (Minute.To)
            {
                Hour--;
            }

            return(Hour + Minute);
        }
示例#7
0
        public void op_AdditionTest()
        {
            TimeWords c1 = new TimeWords();
            TimeWords c2 = new TimeWords();
            TimeWords expected = new TimeWords();

            c1.Eight = true;
            c2.FiveMinute = true;
            c2.To = true;

            expected.Eight = true;
            expected.FiveMinute = true;
            expected.To = true;
            TimeWords actual;
            actual = (c1 + c2);
            Assert.AreEqual(expected, actual);
        }
示例#8
0
        public void op_Decrement_Reduces_Hour()
        {
            TimeWords c1 = new TimeWords();
            TimeWords expected = new TimeWords();

            c1.Eight = true;
            c1.FiveMinute = true;
            c1.To = true;

            expected.Seven = true;
            expected.FiveMinute = true;
            expected.To = true;

            TimeWords actual;
            actual = --(c1);
            Assert.AreEqual(expected, actual);
        }
示例#9
0
        public virtual TimeWords GetHour(TimeSpan Time)
        {
            TimeWords Hour = new TimeWords();

            switch (Time.Hours % 12)
            {
            case 0: Hour.Twelve = true; break;

            case 1: Hour.One = true; break;

            case 2: Hour.Two = true; break;

            case 3: Hour.Three = true; break;

            case 4: Hour.Four = true; break;

            case 5: Hour.Five = true; break;

            case 6: Hour.Six = true; break;

            case 7: Hour.Seven = true; break;

            case 8: Hour.Eight = true; break;

            case 9: Hour.Nine = true; break;

            case 10: Hour.Ten = true; break;

            case 11: Hour.Eleven = true; break;

            case 12: Hour.Twelve = true; break;

            default: throw new NotSupportedException();
            }

            return(Hour);
        }
示例#10
0
        public virtual TimeWords GetHour(TimeSpan Time)
        {
            TimeWords Hour = new TimeWords();

            switch (Time.Hours % 12)
            {
                case 0: Hour.Twelve = true; break;
                case 1: Hour.One = true; break;
                case 2: Hour.Two = true; break;
                case 3: Hour.Three = true; break;
                case 4: Hour.Four = true; break;
                case 5: Hour.Five = true; break;
                case 6: Hour.Six = true; break;
                case 7: Hour.Seven = true; break;
                case 8: Hour.Eight = true; break;
                case 9: Hour.Nine = true; break;
                case 10: Hour.Ten = true; break;
                case 11: Hour.Eleven = true; break;
                case 12: Hour.Twelve = true; break;
                default: throw new NotSupportedException();
            }

            return Hour;
        }
示例#11
0
        public virtual TimeWords GetMinute(TimeSpan Time)
        {
            TimeWords Minute = new TimeWords();

            switch (Time.Minutes)
            {
            case 58:
            case 59:
            case 0:
            case 1:
            case 2: return(Minute);

            case 3:
            case 4:
            case 5:
            case 6:
            case 7: Minute.FiveMinute = true; break;

            case 8:
            case 9:
            case 10:
            case 11:
            case 12: Minute.TenMinute = true; break;

            case 13:
            case 14:
            case 15:
            case 16:
            case 17: Minute.Quarter = true; break;

            case 18:
            case 19:
            case 20:
            case 21:
            case 22: Minute.Twenty = true; break;

            case 23:
            case 24:
            case 25:
            case 26:
            case 27: Minute.Twenty = true; Minute.FiveMinute = true; break;

            case 28:
            case 29:
            case 30:
            case 31:
            case 32: Minute.Half = true; break;

            case 33:
            case 34:
            case 35:
            case 36:
            case 37: Minute.Twenty = true; Minute.FiveMinute = true; break;

            case 38:
            case 39:
            case 40:
            case 41:
            case 42: Minute.Twenty = true; break;

            case 43:
            case 44:
            case 45:
            case 46:
            case 47: Minute.Quarter = true; break;

            case 48:
            case 49:
            case 50:
            case 51:
            case 52: Minute.TenMinute = true; break;

            case 53:
            case 54:
            case 55:
            case 56:
            case 57: Minute.FiveMinute = true; break;



            default: throw new NotSupportedException();
            }

            //To: 33-57
            //Past: 3-27
            string Modifier = string.Empty;

            if ((Time.Minutes) >= 33 & (Time.Minutes) <= 57)
            {
                Minute.To = true;
            }
            else if ((Time.Minutes) >= 3 & (Time.Minutes) <= 27)
            {
                Minute.Past = true;
            }


            return(Minute);
        }
 public void GetMinute_Returns_Null_For_Low_Numbers()
 {
     TimeWords expected = new TimeWords();
     var actual = RunGetMinuteTest(new TimeSpan(1, 2, 3));
     Assert.AreEqual(expected, actual);
 }
示例#13
0
        public void op_Decrement_Reduces_Hour_From_One_To_Twelve()
        {
            TimeWords c1 = new TimeWords();
            TimeWords expected = new TimeWords();

            c1.One = true;
            c1.FiveMinute = true;
            c1.To = true;

            expected.Twelve = true;
            expected.FiveMinute = true;
            expected.To = true;

            TimeWords actual;
            actual = --(c1);
            Assert.AreEqual(expected, actual);
        }
 public void GetMinute_Returns_Five_Past()
 {
     TimeWords expected = new TimeWords();
     expected.FiveMinute = true; expected.Past = true;
     var actual = RunGetMinuteTest(new TimeSpan(1, 4, 3));
     Assert.AreEqual(expected, actual);
 }
 public void GetTime_Returns_Five_To_Two_On_One_Fifty_Five()
 {
     FancyClockFormatter target = new FancyClockFormatter();
     TimeSpan Time = new TimeSpan(1, 55, 3);
     TimeWords expected = new TimeWords();
     expected.Two = true; expected.FiveMinute = true; expected.To = true;
     var actual = target.GetTime(Time);
     Assert.AreEqual(expected, actual);
 }
示例#16
0
        public virtual TimeWords GetTime(TimeSpan Time)
        {
            TimeWords Hour = new TimeWords();
            Hour = GetHour(Time);
            TimeWords Minute = new TimeWords();
            Minute = GetMinute(Time);

            if (Minute.To)
                Hour--;

            return Hour + Minute;
        }
示例#17
0
        public virtual TimeWords GetMinute(TimeSpan Time)
        {
            TimeWords Minute = new TimeWords();
            switch (Time.Minutes)
            {
                case 58:
                case 59:
                case 0:
                case 1:
                case 2: return Minute;
                case 3:
                case 4:
                case 5:
                case 6:
                case 7: Minute.FiveMinute=true; break;
                case 8:
                case 9:
                case 10:
                case 11:
                case 12: Minute.TenMinute = true; break;
                case 13:
                case 14:
                case 15:
                case 16:
                case 17: Minute.Quarter = true; break;
                case 18:
                case 19:
                case 20:
                case 21:
                case 22: Minute.Twenty = true; break;
                case 23:
                case 24:
                case 25:
                case 26:
                case 27: Minute.Twenty = true; Minute.FiveMinute = true; break;
                case 28:
                case 29:
                case 30:
                case 31:
                case 32: Minute.Half = true; break;
                case 33:
                case 34:
                case 35:
                case 36:
                case 37: Minute.Twenty = true; Minute.FiveMinute = true; break;
                case 38:
                case 39:
                case 40:
                case 41:
                case 42: Minute.Twenty = true; break;
                case 43:
                case 44:
                case 45:
                case 46:
                case 47: Minute.Quarter = true; break;
                case 48:
                case 49:
                case 50:
                case 51:
                case 52: Minute.TenMinute = true; break;
                case 53:
                case 54:
                case 55:
                case 56:
                case 57: Minute.FiveMinute = true; break;

                default: throw new NotSupportedException();
            }

            //To: 33-57
            //Past: 3-27
            string Modifier = string.Empty;
            if ((Time.Minutes) >= 33 & (Time.Minutes) <= 57)
                Minute.To = true;
            else if ((Time.Minutes) >= 3 & (Time.Minutes) <= 27)
                Minute.Past = true;

            return Minute;
        }
示例#18
0
        public static TimeWords operator +(TimeWords c1, TimeWords c2)
        {
            var value = new TimeWords();
            value.Half = c1.Half || c2.Half;
            value.TenMinute = c1.TenMinute || c2.TenMinute;
            value.Quarter = c1.Quarter || c2.Quarter;
            value.Twenty = c1.Twenty || c2.Twenty;
            value.FiveMinute = c1.FiveMinute || c2.FiveMinute;
            value.Minutes = c1.Minutes || c2.Minutes;
            value.To = c1.To || c2.To;
            value.Past = c1.Past || c2.Past;
            value.One = c1.One || c2.One;
            value.Two = c1.Two || c2.Two;
            value.Three = c1.Three || c2.Three;
            value.Four = c1.Four || c2.Four;
            value.Five = c1.Five || c2.Five;
            value.Six = c1.Six || c2.Six;
            value.Seven = c1.Seven || c2.Seven;
            value.Eight = c1.Eight || c2.Eight;
            value.Nine = c1.Nine || c2.Nine;
            value.Ten = c1.Ten || c2.Ten;
            value.Eleven = c1.Eleven || c2.Eleven;
            value.Twelve = c1.Twelve || c2.Twelve;
            value.OClock = c1.OClock || c2.OClock;

            return value;
        }
 public void GetMinute_Returns_Five_To_On_Fifty_Five()
 {
     TimeWords expected = new TimeWords();
     expected.FiveMinute = true; expected.To = true;
     var actual = RunGetMinuteTest(new TimeSpan(1, 55, 3));
     Assert.AreEqual(expected, actual);
 }