Exemplo n.º 1
0
        public void NonNumericThrows()
        {
            //Arrange
            string      input = "aaa";
            IntegerTime testObj;

            //Act
            testObj = new IntegerTime(input);

            //Assert
            //Throws
        }
Exemplo n.º 2
0
        public void SQLCtor_GivesCorrectHour_ShortHour()
        {
            //Arrange
            string      input    = "85023";
            int         expected = 8;
            IntegerTime testObj;

            //Act
            testObj = new IntegerTime(input);

            //Assert
            Assert.AreEqual(expected, testObj.Hour);
        }
Exemplo n.º 3
0
        public void DateTimeCtor_GivesCorrectHour()
        {
            //Arrange
            DateTime    input    = new DateTime(2018, 5, 16, 14, 26, 1);
            int         expected = 14;
            IntegerTime testObj;

            //Act
            testObj = new IntegerTime(input);

            //Assert
            Assert.AreEqual(expected, testObj.Hour);
        }
Exemplo n.º 4
0
        public void ToString_Correct()
        {
            //Arrange
            string      input    = "82536";
            string      expected = "82536";
            IntegerTime testObj;

            //Act
            testObj = new IntegerTime(input);

            //Assert
            Assert.AreEqual(expected, testObj.ToString());
        }
Exemplo n.º 5
0
        public void ToInt32_Correct()
        {
            //Arrange
            string      input    = "82536";
            int         expected = 82536;
            IntegerTime testObj;

            //Act
            testObj = new IntegerTime(input);

            //Assert
            Assert.AreEqual(expected, testObj.ToInt);
        }
Exemplo n.º 6
0
        public void ToTimeSpan()
        {
            //Arrange
            string      input    = "85023";
            TimeSpan    expected = new TimeSpan(08, 50, 23);
            IntegerTime testObj;

            //Act
            testObj = new IntegerTime(input);

            //Assert
            Assert.AreEqual(expected, testObj.ToTimeSpan);
        }
Exemplo n.º 7
0
        public void SQLCtor_GivesCorrectSecond()
        {
            //Arrange
            string input    = "85023";
            int    expected = 23;

            IntegerTime testObj;

            //Act
            testObj = new IntegerTime(input);

            //Assert
            Assert.AreEqual(expected, testObj.Second);
        }
Exemplo n.º 8
0
        public void SQLCtor_GivesCorrectMinute()
        {
            //Arrange
            string input    = "85023";
            int    expected = 50;

            IntegerTime testObj;

            //Act
            testObj = new IntegerTime(input);

            //Assert
            Assert.AreEqual(expected, testObj.Minute);
        }
Exemplo n.º 9
0
        public void SQLCtor_ZeroInputWorks()
        {
            //Arrange
            string input = "0";

            IntegerTime testObj;

            //Act
            testObj = new IntegerTime(input);

            //Assert
            Assert.AreEqual(0, testObj.Hour);
            Assert.AreEqual(0, testObj.Minute);
            Assert.AreEqual(0, testObj.Second);
        }
Exemplo n.º 10
0
        public void IntCtor_GivesCorrectHourMinuteSecond()
        {
            //Arrange
            int         expectedHour   = 10;
            int         expectedMinute = 11;
            int         expectedSecond = 12;
            int         input          = (expectedHour * 10000) + (expectedMinute * 100) + expectedSecond;
            IntegerTime testObj;

            //Act
            testObj = new IntegerTime(input);

            //Assert
            Assert.AreEqual(expectedHour, testObj.Hour);
            Assert.AreEqual(expectedMinute, testObj.Minute);
            Assert.AreEqual(expectedSecond, testObj.Second);
        }
Exemplo n.º 11
0
        public void IntegerTimeReadmeTest()
        {
            // Find date components
            IntegerTime fromString = new IntegerTime("010203");

            Assert.AreEqual(1, fromString.Hour);
            Assert.AreEqual(2, fromString.Minute);
            Assert.AreEqual(3, fromString.Second);

            IntegerTime fromInt = new IntegerTime(101112);

            Assert.AreEqual(10, fromInt.Hour);
            Assert.AreEqual(11, fromInt.Minute);
            Assert.AreEqual(12, fromInt.Second);

            // Convert
            Assert.AreEqual(10203, fromString.ToInt);
            Assert.AreEqual("101112", fromInt.ToString());

            Assert.AreEqual(10, fromInt.ToTimeSpan.Hours);
            Assert.AreEqual(11, fromInt.ToTimeSpan.Minutes);
            Assert.AreEqual(12, fromInt.ToTimeSpan.Seconds);
        }