public void CalculateFare_Card(double expectedfare) { //Arrange var fareCapMock = Substitute.For <IFareCapService>(); fareCapMock.ApplyFareCap(Arg.Any <Journey>(), Arg.Any <double>()).Returns(expectedfare); var fareCapService = new FareRuleService(fareCapMock, Host.Instance.Get <ILogService>()); fareCapService.AddFareRule(new PeakHourRule()); fareCapService.AddFareRule(new OffPeakHourRule()); var journey = GetNewJourney(); // Act var fare = fareCapService.CalculateFare(new Card() { TotalJourneys = new List <Journey>() { journey } }); // Assert Assert.Equal(expectedfare, fare); }
public void CalculateFare_NoRulesDefined_Exception() { //Arrange var fareCapMock = Substitute.For <IFareCapService>(); var fareCapService = new FareRuleService(fareCapMock, Host.Instance.Get <ILogService>()); var journey = GetNewJourney(); // Act void action() => fareCapService.CalculateFare(journey); // Assert Assert.Throws <InvalidOperationException>(action); }