Story seven :
– Monthly View should allow the user to change a ‘vacation’ to working day.
Here’s the acidtest :
public class GoToWorkAcidTest : MonthViewAcidTest, IDisposable
{
public void Dispose()
{
ReportSpecsTested();
}
[SpecFor(typeof(GoToWorkTransition))]
public Spec ChangeWorkingDay_ShouldBeWorkingDay(DateTime i, Null o)
{
return
new Spec(() => Ensure.Equal("workingday", GetInputDayFromMonthview(i).Type))
.If(() => GetInputDayFromMonthview(i).Type == "workingday");
}
[SpecFor(typeof(GoToWorkTransition))]
public Spec ChangeVacation_ShouldBeWorkingDay(DateTime i, Null o)
{
return
new Spec(() => Ensure.Equal("workingday", GetInputDayFromMonthview(i).Type))
.If(() => GetInputDayFromMonthview(i).Type == "vacation");
}
[SpecFor(typeof(GoToWorkTransition))]
public Spec ChangeNotWeekend_ShouldBeWorkingDay(DateTime i, Null o)
{
return
new Spec(() => Ensure.Equal("workingday", GetInputDayFromMonthview(i).Type))
.If(() => GetInputDayFromMonthview(i).Type != "weekend");
}
[SpecFor(typeof(GoToWorkTransition))]
public Spec WeekendsCannotBeChangedtoWorkingday(DateTime i, Null o)
{
return
new Spec(() => Ensure.Equal("weekend", GetInputDayFromMonthview(i).Type))
.If(() => GetInputDayFromMonthview(i).Type == "weekend");
}
}
As you can see, it is pretty much a mirror image from the TakeTheDayOff one.
Except this test outputs something like :
Test 'Registered Spec not evaluated' failed: QuickNet.Exceptions.UnregisteredPropertiesException : GoToWorkTransition ChangeVacation_ShouldBeWorkingDay
C:\Projects\quicknet\ quicknet\QuickNet\Reporting\TestRunReport.cs(58,0): at QuickNet.Reporting.TestRunReport.CheckForRegisteredButUntestedSpecs()
Output from Registered Spec not evaluated:
733 : GoToWorkTransition ChangeWorkingDay_ShouldBeWorkingDay.
733 : GoToWorkTransition ChangeNotWeekend_ShouldBeWorkingDay.
267 : GoToWorkTransition WeekendsCannotBeChangedtoWorkingday.
------------------------------------------------------------
Registered but untested :
GoToWorkTransition ChangeVacation_ShouldBeWorkingDay
------------------------------------------------------------
0 passed, 1 failed, 0 skipped, took 3,64 seconds (xunit).
In order to get quicknet to test that spec and thus pass, we need to setup some vacation days.
Decorating the acidtest with the following :
[Using(typeof(TakeTheDayOffTransition))]
solves the issue and the test now outputs something like :
Output from VerifyAll:
334 : GoToWorkTransition ChangeWorkingDay_ShouldBeWorkingDay.
12 : GoToWorkTransition ChangeVacation_ShouldBeWorkingDay.
346 : GoToWorkTransition ChangeNotWeekend_ShouldBeWorkingDay.
128 : GoToWorkTransition WeekendsCannotBeChangedtoWorkingday.
------------------------------------------------------------
1 passed, 0 failed, 0 skipped, took 3,57 seconds (xunit).