public void IfValueIsMinDateTime_ReturnEmptySting()
        {
            object parameter = string.Empty;
            var value = DateTime.MinValue;
            var converter = new DateTimeFormatConverter();

            var result = converter.Convert(value, typeof(object), parameter, CultureInfo.InvariantCulture);

            Assert.AreEqual(result, string.Empty);
        }
        public void IfValueIsNull_ReturnNull()
        {
            object parameter = string.Empty;
            object value = null;
            var converter = new DateTimeFormatConverter();

            var result = converter.Convert(value, typeof(object), parameter, CultureInfo.InvariantCulture);

            Assert.AreEqual(result, null);
        }
        public void Convert()
        {
            var converter = new DateTimeFormatConverter();

            var date = converter.Convert(null, null, null, null);
            Assert.IsNull(date);

            date = converter.Convert(DateTime.MinValue, null, null, null);
            Assert.AreEqual(string.Empty, date);

            var expectedDate = DateTime.Today;

            date = converter.Convert(expectedDate, null, DateTimeFormat.Date.ToString(), null);
            Assert.AreEqual(expectedDate.ToShortDateString(), date);

            date = converter.Convert(expectedDate, null, DateTimeFormat.Time.ToString(), CultureInfo.CurrentCulture);
            Assert.AreEqual(expectedDate.ToShortTimeString(), date);

            date = converter.Convert(expectedDate, null, DateTimeFormat.DateTime.ToString(), null);
            Assert.AreEqual(expectedDate.ToString(CultureInfo.CurrentCulture), date);
        }
        public void ConvertTest()
        {
            const int Year = 2012;
            const int Month = 1;
            const int Day = 2;
            const int Hour = 3;
            const int Minute = 4;
            const int Sec = 5;

            object parameter = DateTimeFormat.Date.ToString();
            var value = new DateTime(Year, Month, Day, Hour, Minute, Sec);
            var converter = new DateTimeFormatConverter();

            var result = converter.Convert(value, typeof(object), parameter, CultureInfo.InvariantCulture);
            Assert.AreEqual(result, value.ToShortDateString());
            
            parameter = DateTimeFormat.Time.ToString();
            result = converter.Convert(value, typeof(object), parameter, CultureInfo.InvariantCulture);
            Assert.AreEqual(result, value.ToShortTimeString());

            parameter = DateTimeFormat.DateTime.ToString();
            result = converter.Convert(value, typeof(object), parameter, CultureInfo.InvariantCulture);
            Assert.AreEqual(result, value.ToString(CultureInfo.InvariantCulture));
        }