public void Is_converter_returning_correct_string_from_given_datetime_type(int hour, int min, string hourAndMinString) { var time = new DateTime(2000, 1, 2, hour, min, 5); var conv = new TimeToStringConverter(); Assert.AreEqual(hourAndMinString, conv.Convert(time, typeof(string), null, CultureInfo.CurrentCulture)); }
public void Test_Convert_Given_Invalid_Time_Returns_Null() { var converter = new TimeToStringConverter(); var inputTime = "25, 30, 35"; var result = converter.ConvertBack(inputTime, typeof(TimeSpan), null, CultureInfo.CurrentCulture); Assert.Null(result); }
public void Test_Convert_Given_01_30_35_Returns_Input_As_String() { var converter = new TimeToStringConverter(); var time = new TimeSpan(1, 30, 35); var result = converter.Convert(time, typeof(string), null, CultureInfo.CurrentCulture); Assert.Equal("01:30:35", result); }
public void Test_ConvertBack_Given_01_30_35_Returns_Input_As_Datetime() { var converter = new TimeToStringConverter(); var inputTime = "1, 30, 35"; var expectedTime = new TimeSpan(01, 30, 35); var result = converter.ConvertBack(inputTime, typeof(TimeSpan), null, CultureInfo.CurrentCulture); Assert.Equal(expectedTime, result); }
public void ConvertTo_NullTime_NullString() { // Arrange var converter = new TimeToStringConverter(false, true); string convertedTime = ""; // Act & Assert Assert.DoesNotThrow(() => convertedTime = (string)converter.ConvertTo(null, typeof(string))); Assert.IsNull(convertedTime); }
public void ConvertTo_WithDetail_StringWithoutHourAndWithMs() { // Arrange var converter = new TimeToStringConverter(false, true); // Act string convertedTime = (string)converter.ConvertTo(new Time(100002), typeof(string)); // Assert Assert.AreEqual("1:40,002", convertedTime); }
public void ConvertTo_IncludeHourWithDetail_StringWithHourAndMs() { // Arrange var converter = new TimeToStringConverter(true, true); // Act string convertedTime = (string)converter.ConvertTo(new Time(100002), typeof(string)); // Assert Assert.AreEqual("0:01:40,002", convertedTime); }
public void ConvertTo_NoIncludeHourButHasHour_StringWithHour() { // Arrange var converter = new TimeToStringConverter(false, false); // Act string convertedTime = (string)converter.ConvertTo(new Time(10000002), typeof(string)); // Assert Assert.AreEqual("2:46:40", convertedTime); }
public void ConvertTo_DefaultConverter_StringWithoutHourOrMs() { // Arrange var converter = new TimeToStringConverter(false, false); // Act string convertedTime = (string)converter.ConvertTo(new Time(100002), typeof(string)); // Assert Assert.AreEqual("1:40", convertedTime); }
static Cvt() { And = new AndConverter(); AndVis = new AndVisibilityConverter(); Or = new OrConverter(); OrVis = new OrVisibilityConverter(); Eq = new EqualToConverter(); EqVis = new EqualToVisibilityConverter(); Neq = new NotEqualToConverter(); NeqVis = new NotEqualToVisibilityConverter(); DoNothing = new DoNothingConverter(); GridLength = new GridLengthValueConverter(); IsNull = new IsNullConverter(); B2Vis = new BooleanToVisibilityConverter(); T2S = new TimeToStringConverter(); Dt2S = new DateTimeToStringConverter(); D2S = new DateToStringConverter(); I2D = new IntToDoubleConverter(); }