public void ShouldReportEachTaskStartTimeAsAString(int index, string expectedTime) { var sut = new DailyTaskList(new DateTime(2020, 3, 26), new TimeSpan(10, 0, 0)); sut.Generate <TaskItem>(6); Assert.That(sut[index].StartTimeString, Is.EqualTo(expectedTime)); }
private static void generateTasksList() { // Create a new dailyTaskList, starting today at 8:00am DateTime startDate = DateTime.Today; TimeSpan startTime = new TimeSpan(8, 0, 0); dailyTaskList = new DailyTaskList(startDate, startTime); int numberOfSegments = -1; // The number of segments requested by the user bool isValidNumber = false; // If the number of segments requested is valid while (!isValidNumber) { Console.Write("How many half-hour segments? "); // Get user input isValidNumber = int.TryParse(Console.ReadLine(), out numberOfSegments); // Validate user input // isValidNumber is set to either true or false depending on if the parsing was successful. // So, we want to make sure that isValidNumber is false if the user didn't even enter a number. // The next validation check is to ensure that the user requested at least 1 segment. // The final validation check is to limit the number of possible segments to 48. // It must be constrainted to 48 because that is the maximum number of 30-minute segments within a day (24hr). isValidNumber = isValidNumber && numberOfSegments > 0 && numberOfSegments <= 48; } dailyTaskList.Generate<TaskItem>(numberOfSegments); }
public void ShouldReportEachTaskDescriptionAsHyphenWhenNoTask() { var sut = new DailyTaskList(new DateTime(2020, 3, 26), new TimeSpan(10, 0, 0)); sut.Generate <TaskItem>(6); for (int i = 0; i < sut.NumberOfTasks; i++) { Assert.That(sut[i].Description, Is.EqualTo("-")); } }
public void ShouldReportTheEndTime() { var dateTime = new DateTime(2020, 3, 26); var timeSpan = new TimeSpan(8, 0, 0); var sut = new DailyTaskList(dateTime, timeSpan); sut.Generate <TaskItem>(11); var actual = sut.EndTime; var expected = "1:00pm"; Assert.That(actual, Is.EqualTo(expected)); }
public void ShouldReportTheNumberOfTasks() { const int NUMBER_OF_TASKS = 11; var dateTime = new DateTime(2020, 3, 26); var timeSpan = new TimeSpan(8, 0, 0); var sut = new DailyTaskList(dateTime, timeSpan); sut.Generate <FakeTaskItem>(NUMBER_OF_TASKS); var actual = sut.NumberOfTasks; var expected = NUMBER_OF_TASKS; Assert.That(actual, Is.EqualTo(expected)); }