Ejemplo n.º 1
0
 public void ParseTest()
 {
     Assert.AreEqual(new MinuteSecond(09, 52), MinuteSecond.Parse("09:52"));
     Assert.AreEqual(new MinuteSecond(09, 52), MinuteSecond.Parse("09:52:51"));
     Assert.AreEqual(new MinuteSecond(09, 03), MinuteSecond.Parse("9:03"));
     Assert.AreEqual(new MinuteSecond(21, 03), MinuteSecond.Parse("21:3"));
     Assert.AreEqual(new MinuteSecond(09, 03), MinuteSecond.Parse("9:3"));
 }
Ejemplo n.º 2
0
        public void PropertySetterTest()
        {
            var ms = new MinuteSecond();

            ms.TotalHours = 0.125;
            Assert.AreEqual(new MinuteSecond(07, 30), ms);
            ms.TotalMinutes = 14.25;
            Assert.AreEqual(new MinuteSecond(14, 15), ms);
            ms.Minute = 16;
            Assert.AreEqual(new MinuteSecond(16, 15), ms);
            ms.Second = 42;
            Assert.AreEqual(new MinuteSecond(16, 42), ms);
        }
Ejemplo n.º 3
0
        public void SubtractTest()
        {
            var ms = new MinuteSecond(12, 01);

            ms.Subtract(4);
            Assert.AreEqual(new MinuteSecond(11, 57), ms);
            ms.Subtract(4);
            Assert.AreEqual(new MinuteSecond(11, 53), ms);
            ms.Subtract(62);
            Assert.AreEqual(new MinuteSecond(10, 51), ms);

            ms.Subtract(1, 4);
            Assert.AreEqual(new MinuteSecond(09, 47), ms);

            Assert.AreEqual(new MinuteSecond(14, 37), new MinuteSecond(15, 00) - 23);
            Assert.AreEqual(new MinuteSecond(13, 37), new MinuteSecond(15, 00) - new MinuteSecond(01, 23));
        }
Ejemplo n.º 4
0
        public void AddTest()
        {
            var ms = new MinuteSecond(11, 53);

            ms.Add(4);
            Assert.AreEqual(new MinuteSecond(11, 57), ms);
            ms.Add(4);
            Assert.AreEqual(new MinuteSecond(12, 01), ms);
            ms.Add(62);
            Assert.AreEqual(new MinuteSecond(13, 03), ms);

            ms.Add(1, 4);
            Assert.AreEqual(new MinuteSecond(14, 07), ms);

            Assert.AreEqual(new MinuteSecond(15, 00), new MinuteSecond(14, 37) + 23);
            Assert.AreEqual(new MinuteSecond(15, 00), new MinuteSecond(13, 37) + new MinuteSecond(01, 23));
        }
Ejemplo n.º 5
0
        public void InitializationTest()
        {
            var ms = new MinuteSecond(11, 53);

            AssertProperties();

            ms = new MinuteSecond(11 * 60 + 53);
            AssertProperties();

            void AssertProperties()
            {
                Assert.AreEqual(11, ms.Minute);
                Assert.AreEqual(53, ms.Second);
                Assert.AreEqual(11 * 60 + 53, ms.TotalSeconds);
                Assert.AreEqual(11 + 53 / 60d, ms.TotalMinutes);
                Assert.AreEqual((11 * 60 + 53) / (60d * 60), ms.TotalHours);
            }
        }