public void StringFormatTest() { Time2 strgFormat = new Time2(20, 35, 59); string strgFormatCopy = "20:35:59"; Assert.AreEqual(strgFormatCopy, strgFormat.ToUniversalString()); }
public void NegativeToStringTest2() { Time2 strgFormat = new Time2(13, 35, 59); string strgFormatCopy = "13:35:59 AM"; Assert.AreNotEqual(strgFormatCopy, strgFormat.ToUniversalString()); }
public void NegativeToStringTest() { Time2 strgFormat = new Time2(9, 35, 59); string strgFormatCopy = "9:35:59 PM"; Assert.AreNotEqual(strgFormatCopy, strgFormat.ToString()); }
public void ToStringTest() { Time2 strgFormat = new Time2(9, 35, 59); string strgFormatCopy = "9:35:59 AM"; Assert.AreEqual(strgFormatCopy, strgFormat.ToString()); }
public void PositiveSecondTest() { Time2 scnd = new Time2(0, 29, 58); Assert.AreEqual(58, scnd.Second); Time2 scnd2 = new Time2(0, 29, 58); Assert.AreNotEqual(50, scnd2.Second); }
public void PositiveMinuteTest() { Time2 mnt = new Time2(2, 59, 59); Assert.AreEqual(59, mnt.Minute); Time2 mnt2 = new Time2(2, 59, 59); Assert.AreNotEqual(50, mnt2.Minute); }
public void PositiveHourTest() { Time2 hr = new Time2(20, 59, 59); Assert.AreEqual(20, hr.Hour); Time2 hr2 = new Time2(20, 59, 59); Assert.AreNotEqual(24, hr2.Hour); }
public void NegativeHourTest() { try { Time2 hr = new Time2(24, 59, 59); } catch (System.Exception) { } finally { Console.WriteLine("out of range"); } }
public void NegativeSecondTest() { try { Time2 scnd = new Time2(0, 29, -1); } catch (System.Exception) { } finally { Console.WriteLine("out of range"); } }
public void NegativeMinuteTest() { try { Time2 mnt = new Time2(2, -1, 59); } catch (System.Exception) { } finally { Console.WriteLine("out of range"); } }
static void Main(string[] args) { int hour = 0; int minute = 0; int second = 0; hour = Console.Read(); minute = Console.Read(); second = Console.Read(); Time2 time = new Time2(hour, minute, second); }
// Time2 constructor: another Time2 object supplied as an argument public Time2(Time2 time) : this(time.Hour, time.Minute, time.Second) { }