Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using Machine.Specifications;
using Given = Machine.Specifications.Establish;
using When = Machine.Specifications.Because;
using Then = Machine.Specifications.It;
namespace TryMSpec {
public class TicketCalculator{
private decimal _ticket_price = 11m;
public void StartPurchase(int runtime, DayOfWeek day, bool isParquet, bool is3D) {}
public void AddTicket(int age, bool isStudent){
if (isStudent)
_ticket_price = 8m;
}
public decimal FinishPurchase(){ return _ticket_price; }
}
public class Given_i_buy_a_standard_ticket{
protected static TicketCalculator _calculator;
Given i_buy_a_standard_movie_ticket = () => {
_calculator = new TicketCalculator();
_calculator.StartPurchase(115, DayOfWeek.Monday, true, false);
};
}
[Subject("Basic admission rates")]
public class Purchasing_general_ticket_as_an_adult_non_student :
Given_i_buy_a_standard_ticket {
When i_purchase_it_for_an_adult_non_student = () => _calculator.AddTicket(33, false);
Then i_pay_11_bucks = () => _calculator.FinishPurchase().ShouldEqual(11m);
}
[Subject("Basic admission rates")]
public class Purchasing_general_ticket_as_an_adult_student :
Given_i_buy_a_standard_ticket{
When i_purchase_it_for_an_adult_student = () => _calculator.AddTicket(33, true);
Then i_pay_8_bucks = () => _calculator.FinishPurchase().ShouldEqual(8m);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.