public void ConvertTime() { TimeTodo testData = new TimeTodo(); testData = TimeTodo.ConvertTime(1); Assert.That(testData.Value, Is.EqualTo(1 / 60.0)); Assert.That(testData.Type, Is.EqualTo("I")); testData = TimeTodo.ConvertTime(61); Assert.That(testData.Value, Is.EqualTo(61 / 3600.0)); Assert.That(testData.Type, Is.EqualTo("H")); }
public static int ConvertToSeconds(TimeTodo timeTodo) { int returnValue = 0; switch (timeTodo.Type) { case "I": returnValue = Convert.ToInt32(Math.Floor(timeTodo.Value * 60)); break; case "H": returnValue = Convert.ToInt32(Math.Floor(timeTodo.Value * 60 * 60)); break; } return returnValue; }
public static TimeTodo ConvertTime(double value) { TimeTodo returnvalue = new TimeTodo(); if (value <= 3600) { returnvalue.Type = "I"; returnvalue.Value = value / 60; } else { returnvalue.Type = "H"; returnvalue.Value = value / 3600.0; } return returnvalue; }