public void TaskConstructorTest() { Task target = new Task(); Assert.IsNotNull(target); Assert.IsInstanceOfType(target,typeof(Object)); Assert.AreEqual(target.Name, ""); Assert.AreEqual(target.Time, TimeSpan.Zero); Assert.IsInstanceOfType(target.TimeString, typeof(String)); }
public void NameTest() { Task target = new Task(); string expected = "Test String"; string actual; target.Name = expected; actual = target.Name; Assert.AreEqual(expected, actual); }
public void IsCheckedTest() { Task target = new Task("", TimeSpan.Zero, true); Assert.IsTrue(target.IsChecked); bool expected = false; bool actual; target.IsChecked = expected; actual = target.IsChecked; Assert.AreEqual(expected, actual); }
// Update the time of the checked task or all the tasks if you have to. // It will run whenever the timer tick updates a task's time. private void updateTimes(Task aTask) { int taskIndex = myTasks.IndexOf(aTask); myTimeLabels[taskIndex].Text = aTask.TimeString; // Updates the title of the form in case you've changed the text of a task without checking in again this.Text = myTextBoxes[taskIndex].Text; }
private void createTaskControls(Task aTask) { // Create the textBox and set it's text to the task's name. TextBox aTextBox = new TextBox(); aTextBox.Text = aTask.Name; myTextBoxes.Add(aTextBox); // Create the radio button and set it to the checked status RadioButton aRadio = new RadioButton(); aRadio.Click += new EventHandler(aRadio_Click); myRadioButtons.Add(aRadio); aRadio.Width = radioWidth; aRadio.Text = checkInString; if (aTask.IsChecked) { checkInTask(aTask); } // Create the time label and set it to the task's time Label aTimeLabel = new Label(); aTimeLabel.Text = aTask.TimeString; aTimeLabel.Click += new EventHandler(aTimeLabel_Click); aTimeLabel.Width = timeLabelWidth; myTimeLabels.Add(aTimeLabel); // Create the change time text box and set its properties TextBox changeTimeBox = new TextBox(); changeTimeBox.Width = changeTimeBoxWidth; myChangeTimeBoxes.Add(changeTimeBox); }
private void createBlankTasks() { // Create some blank tasks anyway for (int i = 0; i < 2; i++) { Task aTask = new Task("", TimeSpan.Zero, false); myTasks.Add(aTask); } }
// Overload for below method private void checkInTask(Task aTask) { int taskIndex = myTasks.IndexOf(aTask); checkInTask(taskIndex); }
private void buttonAddTask_Click(object sender, EventArgs e) { SaveTaskList(); // I'm only really saving here so that the text in the task fields is saved to the task object. // Add a blank task to the array Task newTask = new Task(); newTask.Name = "New Task"; myTasks.Add(newTask); // wipe out all the buttons and text and task stuff on the form groupBoxTasks.Controls.Clear(); // Create the buttons and stuff for the new task (the other stuff still exists off-form) createTaskControls(newTask); // Add the whole lot of controls back to the form redrawForm(); // Set the text box focus to the newly created task int newTaskIndex = myTasks.IndexOf(newTask); myTextBoxes[newTaskIndex].Focus(); // Set the new task so it's checked in checkOutAllTasks(); checkInTask(newTaskIndex); }
public void TaskConstructorTest1() { string name = "Test Constructor"; TimeSpan time = new TimeSpan(1, 0, 0); bool selected = false; Task target = new Task(name, time, selected); Assert.AreEqual(target.Name, name); Assert.AreEqual(target.Time, time); Assert.AreEqual(target.IsChecked, selected); Assert.AreEqual(target.TimeString, time.Hours.ToString() + ":" + time.Minutes.ToString()); }
public void TimeTest() { Task target = new Task(); TimeSpan expected = new TimeSpan(1,1,1); TimeSpan actual; target.Time = expected; actual = target.Time; Assert.AreEqual(expected, actual); }
public void TimeStringTest() { Task target = new Task(); target.Time = new TimeSpan(3, 2, 1); string expected = "3:2"; string actual = target.TimeString; Assert.AreEqual(expected, actual); }