public void GetValidTo() { // Arrange ParkingMachine machine = new ParkingMachine(30); int days = 5; int hours = 3; int minutes = 2; TimeSpan expectedParkingTime; expectedParkingTime = new TimeSpan( days: days, hours: hours, minutes: minutes, seconds: 0); machine.InsertMoney(1); // 2 minutes machine.InsertMoney(hours * 30); machine.InsertMoney(days * 24 * 30); DateTime expectedValidTo = DateTime.Now; expectedValidTo = expectedValidTo.Add(expectedParkingTime); // Act DateTime validTo = machine.GetValidTo(); // Assert Assert.AreEqual(expectedValidTo.ToString(), validTo.ToString()); }
public void GetParkingTimeSpan() { // Arrange ParkingMachine machine = new ParkingMachine(30); int days = 5; int hours = 3; int minutes = 2; TimeSpan expectedParkingTime; expectedParkingTime = new TimeSpan( days: days, hours: hours, minutes: minutes, seconds: 0); // Act machine.InsertMoney(1); // 2 minutes machine.InsertMoney(hours * 30); machine.InsertMoney(days * 24 * 30); // Assert Assert.AreEqual(expectedParkingTime, machine.GetParkingTimeSpan()); }
public void ValidInsertMoney() { // Arrange ParkingMachine machine = new ParkingMachine(); // Act machine.InsertMoney(30); machine.InsertMoney(60); // Assert Assert.AreEqual(90, machine.CurrentTotal); }
public void BuyTicketTwice_Total_Summed() { // Arrange ParkingMachine machine = new ParkingMachine(); // Act machine.InsertMoney(10); machine.BuyTicket(); machine.InsertMoney(40); machine.BuyTicket(); // Assert Assert.AreEqual(50, machine.Total); }
public void MultipleBuyTicket_CurrentTotal_ZeroAfterBuy() { // Arrange ParkingMachine machine = new ParkingMachine(20); int money = 2 * 24 * 20 + 3 * 20 + 5; // Act machine.InsertMoney(money); machine.BuyTicket(); machine.InsertMoney(money); machine.BuyTicket(); machine.InsertMoney(money); machine.BuyTicket(); // Assert Assert.AreEqual(0, machine.CurrentTotal); }
public void MultipleBuyTicket_Total() { // Arrange ParkingMachine machine = new ParkingMachine(20); int money = 2 * 24 * 20 + 3 * 20 + 5; // Act machine.InsertMoney(money); machine.BuyTicket(); machine.InsertMoney(money); machine.BuyTicket(); machine.InsertMoney(money); machine.BuyTicket(); // Assert Assert.AreEqual(3 * money, machine.Total); }
public void CostPerHour() { // Arrange ParkingMachine machine = new ParkingMachine(40); // Act machine.InsertMoney(30); // Assert Assert.AreEqual(40, machine.CostPerHour); }
public void InvalidInsertMoney() { // Arrange ParkingMachine machine = new ParkingMachine(20); // Act machine.InsertMoney(-30); // Assert Assert.AreEqual(0, machine.CurrentTotal); }
public void BuyTicket3Hour_TicketText() { // Arrange ParkingMachine machine = new ParkingMachine(); // Act machine.InsertMoney(60); string ticketText = machine.BuyTicket(); // Assert Assert.AreEqual(TimeToTicketText(days: 0, hours: 3, minutes: 0), ticketText); }
public void BuyTicket30Min_CurrentTotal_Zeroed() { // Arrange ParkingMachine machine = new ParkingMachine(); // Act machine.InsertMoney(10); machine.BuyTicket(); // Assert Assert.AreEqual(0, machine.CurrentTotal); }
public void Cancel_AmoutRefunded() { // Arrange ParkingMachine machine = new ParkingMachine(20); // Act machine.InsertMoney(100); int refund = machine.Cancel(); // Assert Assert.AreEqual(100, refund); }
public void Cancel_CurrentTotal_Zeroed() { // Arrange ParkingMachine machine = new ParkingMachine(20); // Act machine.InsertMoney(100); int refund = machine.Cancel(); // Assert Assert.AreEqual(0, machine.CurrentTotal); }
public void BuyTicket4Day() { // Arrange ParkingMachine machine = new ParkingMachine(20); // Act machine.InsertMoney(20 * 24 * 4); string ticketText = machine.BuyTicket(); // Assert Assert.AreEqual(TimeToTicketText(days: 4, hours: 0, minutes: 0), ticketText); }
public void BuyTicket30Min() { // Arrange ParkingMachine machine = new ParkingMachine(20); // Act machine.InsertMoney(10); Ticket ticket = machine.BuyTicket(); // Assert Assert.AreEqual(TimeToTicketText(days: 0, hours: 0, minutes: 30), ticket.ToString()); }
public void BuyTicket2Day3Hour15Min_TicketText() { // Arrange ParkingMachine machine = new ParkingMachine(); int money = 2 * 24 * 20 + 3 * 20 + 5; // Act machine.InsertMoney(money); string ticketText = machine.BuyTicket(); // Assert Assert.AreEqual(TimeToTicketText(days: 2, hours: 3, minutes: 15), ticketText); }