public void ParseSunrise_WithGoodData_ReturnsExpectedString() { string expected = "2:35:18 PM"; string result = SunsetTDD.ParseSunrise(sampleData); Assert.AreEqual(expected, result); }
public void GetLocalTime_UTCTimeString_ReturnsLocalTime() { string utcTimeString = "1:35:58 AM"; DateTime currentDate = new DateTime(2015, 02, 15); DateTime expectedLocalTime = new DateTime(2015, 02, 15, 18, 35, 58); DateTime result = SunsetTDD.GetLocalTime(utcTimeString, currentDate); Assert.AreEqual(expectedLocalTime, result); }
public void GetLocalTime_NullTimeString_ReturnsDateOnly() { string utcTimeString = null; DateTime currentDate = new DateTime(2015, 02, 15); DateTime expectedLocalTime = new DateTime(2015, 02, 15, 0, 0, 0); DateTime result = SunsetTDD.GetLocalTime(utcTimeString, currentDate); Assert.AreEqual(expectedLocalTime, result); }
public void GetSunriseGetSunset_CalledWithSameDate_CallsServiceOnce() { DateTime currentDate = new DateTime(2015, 02, 15); Mock <ISunsetService> serviceMock = new Mock <ISunsetService>(); serviceMock.Setup(s => s.GetServiceData(It.IsAny <DateTime>())) .Returns(sampleData); SunsetTDD provider = new SunsetTDD(); provider.SunsetService = serviceMock.Object; DateTime result1 = provider.GetSunrise(currentDate); DateTime result2 = provider.GetSunset(currentDate); serviceMock.Verify(s => s.GetServiceData(currentDate), Times.Once()); }
public void GetSunrise_WithDate_ReturnsSunriseForDate() { DateTime currentDate = new DateTime(2015, 02, 15); DateTime expected = new DateTime(2015, 02, 15, 07, 35, 18); Mock <ISunsetService> serviceMock = new Mock <ISunsetService>(); serviceMock.Setup(s => s.GetServiceData(It.IsAny <DateTime>())) .Returns(sampleData); SunsetTDD provider = new SunsetTDD(); provider.SunsetService = serviceMock.Object; DateTime result = provider.GetSunrise(currentDate); Assert.AreEqual(expected, result); }
static void Main(string[] args) { var sunsetProvider = new SunsetTDD(); var sunset = sunsetProvider.GetSunset(DateTime.Today.AddDays(1)); Console.WriteLine("Sunset Tomorrow: {0}", sunset.ToString("G")); Console.WriteLine("Starting Test"); var controller = new HouseController(); controller.Commander = new FakeCommander(); controller.SendCommand(5, DeviceCommands.On); controller.SendCommand(5, DeviceCommands.Off); var currentTime = DateTime.Now; controller.ScheduleOneTimeItem(currentTime.AddMinutes(1), 1, DeviceCommands.On); controller.ScheduleOneTimeItem(currentTime.AddMinutes(2), 2, DeviceCommands.On); controller.ScheduleOneTimeItem(currentTime.AddMinutes(3), 1, DeviceCommands.Off); controller.ScheduleOneTimeItem(currentTime.AddMinutes(4), 2, DeviceCommands.Off); Console.WriteLine("Test Completed"); string command = ""; while (command != "q") { command = Console.ReadLine(); if (command == "s") { var schedule = controller.GetCurrentScheduleItems(); foreach (var item in schedule) { Console.WriteLine("{0} - {1} ({2}), Device: {3}, Command: {4}", item.Info.EventTime.ToString("G"), item.Info.TimeType.ToString(), item.Info.RelativeOffset.ToString(), item.Device.ToString(), item.Command.ToString()); } } } }
public void GetSunset_CalledWithDifferentDates_CallsServiceMoreThanOnce() { DateTime date1 = new DateTime(2015, 02, 15); DateTime date2 = new DateTime(2015, 02, 16); Mock <ISunsetService> serviceMock = new Mock <ISunsetService>(); serviceMock.Setup(s => s.GetServiceData(It.IsAny <DateTime>())) .Returns(sampleData); SunsetTDD provider = new SunsetTDD(); provider.SunsetService = serviceMock.Object; DateTime result1 = provider.GetSunset(date1); DateTime result2 = provider.GetSunset(date2); serviceMock.Verify(s => s.GetServiceData(It.IsAny <DateTime>()), Times.Exactly(2)); }
public void ParseSunrise_WithErrorData_ReturnsNull() { string result = SunsetTDD.ParseSunrise(errorData); Assert.IsNull(result); }
public void ParseSunrise_WithGoodData_ReturnsString() { string result = SunsetTDD.ParseSunrise(sampleData); Assert.IsNotNull(result); }
public void CheckStatus_WithErrorData_ReturnsFalse() { bool result = SunsetTDD.CheckStatus(errorData); Assert.IsFalse(result); }
public void CheckStatus_WithGoodData_ReturnsTrue() { bool result = SunsetTDD.CheckStatus(sampleData); Assert.IsTrue(result); }