Пример #1
0
        public void ConvertValueToString_UsesUniversalFormat()
        {
            //---------------Set up test pack-------------------
            var dataMapper    = new TimeSpanDataMapper();
            var originalValue = new TimeSpan(TestUtil.GetRandomInt());
            //---------------Execute Test ----------------------
            string strValue = dataMapper.ConvertValueToString(originalValue);

            //---------------Test Result -----------------------
            Assert.AreEqual(originalValue.ToString(), strValue);
        }
Пример #2
0
        public void TryParsePropValue_FailsForOtherTypes()
        {
            //---------------Set up test pack-------------------
            var    dataMapper = new TimeSpanDataMapper();
            object parsedValue;
            //---------------Execute Test ----------------------
            var parsedSucceed = dataMapper.TryParsePropValue(3, out parsedValue);

            //---------------Test Result -----------------------
            Assert.IsFalse(parsedSucceed);
        }
Пример #3
0
        public void TryParsePropValue_WorksForNull()
        {
            //---------------Set up test pack-------------------
            var    dataMapper = new TimeSpanDataMapper();
            object parsedValue;
            //---------------Execute Test ----------------------
            var parseSucceed = dataMapper.TryParsePropValue(null, out parsedValue);

            //---------------Test Result -----------------------
            Assert.IsTrue(parseSucceed);
            Assert.IsNull(parsedValue);
        }
Пример #4
0
        public void TryParsePropValue_WhenGivenADate_OnTheBaseDate_ShouldBeTimeOfDay()
        {
            //---------------Set up test pack-------------------
            var    dataMapper   = new TimeSpanDataMapper();
            var    valueToParse = TimeSpanDataMapper.BaseDate.Add(new TimeSpan(0, 23, 59, 59, 999));
            object parsedValue;
            //---------------Execute Test ----------------------
            var parseSucceed = dataMapper.TryParsePropValue(valueToParse, out parsedValue);

            //---------------Test Result -----------------------
            Assert.IsTrue(parseSucceed);
            Assert.AreEqual(valueToParse.TimeOfDay, parsedValue);
        }
Пример #5
0
        public void TryParsePropValue_WorksForTimeSpan()
        {
            //---------------Set up test pack-------------------
            var    dataMapper   = new TimeSpanDataMapper();
            var    valueToParse = new TimeSpan(TestUtil.GetRandomInt());
            object parsedValue;
            //---------------Execute Test ----------------------
            var parseSucceed = dataMapper.TryParsePropValue(valueToParse, out parsedValue);

            //---------------Test Result -----------------------
            Assert.IsTrue(parseSucceed);
            Assert.AreEqual(valueToParse, parsedValue);
        }
Пример #6
0
        public void TryParsePropValue_WhenString_ShouldConvertCorrectly()
        {
            //---------------Set up test pack-------------------
            var    dataMapper    = new TimeSpanDataMapper();
            var    originalValue = new TimeSpan(TestUtil.GetRandomInt());
            var    valueToParse  = dataMapper.ConvertValueToString(originalValue);
            object parsedValue;
            //---------------Execute Test ----------------------
            var parseSucceed = dataMapper.TryParsePropValue(valueToParse, out parsedValue);

            //---------------Test Result -----------------------
            Assert.IsTrue(parseSucceed);
            Assert.IsInstanceOf(typeof(TimeSpan), parsedValue);
            Assert.AreEqual(originalValue, parsedValue);
        }
Пример #7
0
        public void TryParsePropValue_WhenGivenADate_WithNumberOfDays_ShouldNotLooseNumberOfDays()
        {
            //---------------Set up test pack-------------------
            var    dataMapper   = new TimeSpanDataMapper();
            var    days         = TestUtil.GetRandomInt(1, 500);
            var    valueToParse = TimeSpanDataMapper.BaseDate.Add(TestUtil.GetRandomTimeSpan(days));
            object parsedValue;
            //---------------Execute Test ----------------------
            var parseSucceed = dataMapper.TryParsePropValue(valueToParse, out parsedValue);

            //---------------Test Result -----------------------
            Assert.IsTrue(parseSucceed);
            var timeSpan = (TimeSpan)parsedValue;

            Assert.AreEqual(days, timeSpan.Days);
            Assert.AreEqual(valueToParse.Hour, timeSpan.Hours);
            Assert.AreEqual(valueToParse.Minute, timeSpan.Minutes);
            Assert.AreEqual(valueToParse.Second, timeSpan.Seconds);
            Assert.AreEqual(valueToParse.Millisecond, timeSpan.Milliseconds);
        }