Created
May 21, 2014 11:53
-
-
Save yetanotherchris/51bc6d3e72ef3e0fc47a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using NUnit.Framework; | |
[TestFixture] | |
public class BankHolidayCalculatorTests | |
{ | |
[Test] | |
[TestCase("Jan 1 2015")] | |
[TestCase("Jan 1 2016")] | |
[TestCase("Jan 2 2017")] | |
[TestCase("Jan 1 2018")] | |
[TestCase("Jan 1 2019")] | |
[TestCase("Jan 1 2020")] | |
public void should_be_january_bank_holiday(string date) | |
{ | |
// Arrange | |
DateTime dateTime = DateTime.Parse(date); | |
BankHolidayCalculator calculator = new BankHolidayCalculator(); | |
// Act | |
bool isBankHoliday = calculator.IsJanuaryBankHolidayMonday(dateTime); | |
// Assert | |
Assert.That(isBankHoliday, Is.True); | |
} | |
[Test] | |
public void should_not_be_january_bank_holiday() | |
{ | |
// Arrange | |
DateTime dateTime = DateTime.Parse("Jan 1 2017"); | |
BankHolidayCalculator calculator = new BankHolidayCalculator(); | |
// Act | |
bool isBankHoliday = calculator.IsMayBankHolidayMonday(dateTime); | |
// Assert | |
Assert.That(isBankHoliday, Is.False); | |
} | |
[Test] | |
[TestCase("May 4 2015")] | |
[TestCase("May 25 2015")] | |
[TestCase("May 2 2016")] | |
[TestCase("May 30 2016")] | |
[TestCase("May 1 2017")] | |
[TestCase("May 29 2017")] | |
public void should_be_may_bank_holiday(string date) | |
{ | |
// Arrange | |
DateTime dateTime = DateTime.Parse(date); | |
BankHolidayCalculator calculator = new BankHolidayCalculator(); | |
// Act | |
bool isBankHoliday = calculator.IsMayBankHolidayMonday(dateTime); | |
// Assert | |
Assert.That(isBankHoliday, Is.True); | |
} | |
[Test] | |
public void should_not_be_may_bank_holiday() | |
{ | |
// Arrange | |
DateTime dateTime = DateTime.Parse("May 9 2017"); | |
BankHolidayCalculator calculator = new BankHolidayCalculator(); | |
// Act | |
bool isBankHoliday = calculator.IsMayBankHolidayMonday(dateTime); | |
// Assert | |
Assert.That(isBankHoliday, Is.False); | |
} | |
[Test] | |
[TestCase("August 31 2015")] | |
[TestCase("August 29 2016")] | |
[TestCase("August 28 2017")] | |
[TestCase("August 27 2018")] | |
public void should_be_august_bank_holiday(string date) | |
{ | |
// Arrange | |
DateTime dateTime = DateTime.Parse(date); | |
BankHolidayCalculator calculator = new BankHolidayCalculator(); | |
// Act | |
bool isBankHoliday = calculator.IsAugustBankHolidayMonday(dateTime); | |
// Assert | |
Assert.That(isBankHoliday, Is.True); | |
} | |
[Test] | |
public void should_not_be_august_bank_holiday() | |
{ | |
// Arrange | |
DateTime dateTime = DateTime.Parse("August 14 2017"); | |
BankHolidayCalculator calculator = new BankHolidayCalculator(); | |
// Act | |
bool isBankHoliday = calculator.IsMayBankHolidayMonday(dateTime); | |
// Assert | |
Assert.That(isBankHoliday, Is.False); | |
} | |
[Test] | |
[TestCase("6 April 2015")] | |
[TestCase("28 March 2016")] | |
[TestCase("17 April 2017")] | |
[TestCase("2 April 2018")] | |
[TestCase("22 April 2019")] | |
[TestCase("13 April 2020")] | |
public void should_be_easter_bank_holiday(string date) | |
{ | |
// Arrange | |
DateTime dateTime = DateTime.Parse(date); | |
BankHolidayCalculator calculator = new BankHolidayCalculator(); | |
// Act | |
bool isBankHoliday = calculator.IsEasterBankHolidayMonday(dateTime); | |
// Assert | |
Assert.That(isBankHoliday, Is.True); | |
} | |
[Test] | |
public void should_not_be_easter_bank_holiday() | |
{ | |
// Arrange | |
DateTime dateTime = DateTime.Parse("April 13 2015"); | |
BankHolidayCalculator calculator = new BankHolidayCalculator(); | |
// Act | |
bool isBankHoliday = calculator.IsMayBankHolidayMonday(dateTime); | |
// Assert | |
Assert.That(isBankHoliday, Is.False); | |
} | |
[Test] | |
[TestCase("26 December 2014")] | |
[TestCase("28 December 2015")] | |
[TestCase("27 December 2016")] | |
[TestCase("26 December 2017")] | |
[TestCase("26 December 2018")] | |
[TestCase("26 December 2019")] | |
[TestCase("26 December 2019")] | |
[TestCase("28 December 2020")] | |
public void should_be_december_bank_holiday(string date) | |
{ | |
// Arrange | |
DateTime dateTime = DateTime.Parse(date); | |
BankHolidayCalculator calculator = new BankHolidayCalculator(); | |
// Act | |
bool isBankHoliday = calculator.IsDecemberBankHoliday(dateTime); | |
// Assert | |
Assert.That(isBankHoliday, Is.True); | |
} | |
[Test] | |
public void should_not_be_december_bank_holiday() | |
{ | |
// Arrange | |
DateTime dateTime = DateTime.Parse("29 December 2014"); | |
BankHolidayCalculator calculator = new BankHolidayCalculator(); | |
// Act | |
bool isBankHoliday = calculator.IsMayBankHolidayMonday(dateTime); | |
// Assert | |
Assert.That(isBankHoliday, Is.False); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment