Created
May 2, 2014 15:35
-
-
Save JakeGinnivan/47dfebcb51ee77843f8e 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
void Main() | |
{ | |
this.Given(_ => TheBuyerIsA(_buyerCategory)) | |
.And(_ => TheBuyerSelectsA(fare)) | |
.When(_ => TheBuyerPays()) | |
.Then(_ => ASaleOccursWithAnAmountOf(Price)) | |
.WithExamples(new ExampleTable( | |
"Buyer Category", "Fare", "Price") | |
{ | |
{ BuyerCategory.Student, new MonthlyPass(), new Currency(76) }, | |
{ BuyerCategory.Senior, new MonthlyPass(), new Currency(98) }, | |
{ BuyerCategory.Standard, new MonthlyPass(), new Currency(146) }, | |
{ BuyerCategory.Student, new WeeklyPass(), new Currency(23) }, | |
{ BuyerCategory.Senior, new WeeklyPass(), new Currency(30) }, | |
{ BuyerCategory.Standard, new WeeklyPass(), new Currency(44) }, | |
{ BuyerCategory.Student, new DayPass(), new Currency(4) }, | |
{ BuyerCategory.Senior, new DayPass(), new Currency(5) }, | |
{ BuyerCategory.Standard, new DayPass(), new Currency(7) }, | |
{ BuyerCategory.Student, new SingleTicket(), new Currency(1.5m) }, | |
{ BuyerCategory.Senior, new SingleTicket(), new Currency(2m) }, | |
{ BuyerCategory.Standard, new SingleTicket(), new Currency(3m) } | |
}) | |
.BDDfy("Successful rail card purchases"); | |
} | |
private Fare fare; | |
private BuyerCategory _buyerCategory; | |
Currency Price { get; set; } | |
class Currency | |
{ | |
public Currency(decimal amount) | |
{ | |
Amount = amount; | |
} | |
public decimal Amount { get; set; } | |
public override string ToString() | |
{ | |
return Amount.ToString("C", CultureInfo.CreateSpecificCulture("EN-US")); | |
} | |
} | |
class MonthlyPass : Fare | |
{ | |
public override string ToString() | |
{ | |
return "Monthly Pass"; | |
} | |
} | |
class WeeklyPass : Fare | |
{ | |
public override string ToString() | |
{ | |
return "Weekly Pass"; | |
} | |
} | |
class DayPass : Fare | |
{ | |
public override string ToString() | |
{ | |
return "Day Pass"; | |
} | |
} | |
class SingleTicket : Fare | |
{ | |
public override string ToString() | |
{ | |
return "Day Pass"; | |
} | |
} | |
class Fare | |
{ | |
} | |
enum BuyerCategory | |
{ | |
Student, | |
Senior, | |
Standard | |
} | |
void TheBuyerIsA(BuyerCategory buyerCategory) | |
{ | |
} | |
void TheBuyerSelectsA(Fare fare) | |
{ | |
} | |
void TheBuyerPays() | |
{ | |
} | |
void ASaleOccursWithAnAmountOf(Currency price) | |
{ | |
} | |
// | |
//**Scenario:** Successful rail card purchases | |
//**Given:** the buyer is a <buyer category> | |
//**And:** the buyer selects a <fare> | |
//**When:** the buyer pays | |
//**Then:** a sale occurs with an amount of <price> | |
// | |
//Examples: | |
// | |
// | Buyer Category | Fare | Price | | |
// | Student | Monthly Pass | $76 | | |
// | Senior | Monthly Pass | $98 | | |
// | Standard | Monthly Pass | $146 | | |
// | Student | Weekly Pass | $23 | | |
// | Senior | Weekly Pass | $30 | | |
// | Standard | Weekly Pass | $44 | | |
// | Student | Daily Pass | $4 | | |
// | Senior | Daily Pass | $5 | | |
// | Standard | Daily Pass | $7 | | |
// | Student | Single Ticket | $1.5 | | |
// | Senior | Single Ticket | $2 | | |
// | Standard | Single Ticket | $3 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment