Skip to content
Snippets Groups Projects
Commit 215456d5 authored by Linda Nguyen's avatar Linda Nguyen
Browse files

AddTime test added and works

parent c9423660
No related branches found
No related tags found
3 merge requests!6Change time while cooking,!5Change time while cooking,!4Change time while cooking
Pipeline #194247 passed
......@@ -83,5 +83,13 @@ namespace Microwave.Test.Unit
powerTube.Received().TurnOff();
}
[Test]
public void AddCookingTime_IsCooking_AddTimeCalled()
{
uut.StartCooking(50, 60);
uut.AddCookingTime();
timer.Received().AddTime(10);
}
}
}
\ No newline at end of file
......@@ -147,5 +147,25 @@ namespace Microwave.Test.Unit
Assert.That(uut.TimeRemaining, Is.EqualTo(5-ticks*1));
}
[TestCase(5)]
public void AddTime_Started_TimeRemainingIncreased(int ticks)
{
ManualResetEvent pause = new ManualResetEvent(false);
int ticksGone = 0;
uut.TimerTick += (sender, args) =>
{
ticksGone++;
if (ticksGone >= ticks)
pause.Set();
};
uut.Start(5);
uut.AddTime(2);
// wait for ticks, only a little longer
pause.WaitOne(ticks * 1000 + 100);
Assert.That(uut.TimeRemaining, Is.EqualTo(7 - ticks * 1));
}
}
}
\ No newline at end of file
......@@ -336,6 +336,18 @@ namespace Microwave.Test.Unit
light.Received(1).TurnOff();
}
[Test]
public void AddCookingTime_TimeButtonPressedAfterStart_AddCookingTimeCalled()
{
powerButton.Pressed += Raise.EventWith(this, EventArgs.Empty);
timeButton.Pressed += Raise.EventWith(this, EventArgs.Empty);
startCancelButton.Pressed += Raise.EventWith(this, EventArgs.Empty);
timeButton.Pressed += Raise.EventWith(this, EventArgs.Empty);
cooker.Received().AddCookingTime();
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment