public void ShouldNotThrow() { //arrange //act //assert Expect(() => CardBuilder.Create().Build()) .To.Not.Throw(); }
public void GivenNullJourneyHistory_ShouldThrow() { //arrange //act //assert Expect(() => CardBuilder.Create().WithNullJourneyHistory().Build()) .To.Throw <ArgumentNullException>() .With.Property(err => err.ParamName) .Equal.To("journeyHistory");; }
public void GivenNullDateTimeProvider_ShouldThrow() { //arrange //act //assert Expect(() => CardBuilder.Create().WithNullDateTimeProvider().Build()) .To.Throw <ArgumentNullException>() .With.Property(err => err.ParamName) .Equal.To("dateTimeProvider");; }
public void GivenStation_WithJourneyNoUnderway_ThrowsJourneyException() { //arrange var station = StationBuilder.Create() .Build(); var card = CardBuilder.Create() .Build(); //act //assert Expect(() => card.EndJourney(station)).To.Throw <JourneyException>(); }
public PreparationLogic(int _selectionTargetSize) { for (int i = 0; i < collectionRowsCount; i++) { collection.Add(CardBuilder.Create(Card.Gnome)); collection.Add(CardBuilder.Create(Card.Goblin)); collection.Add(CardBuilder.Create(Card.Demon)); collection.Add(CardBuilder.Create(Card.Elf)); } selectionTargetSize = _selectionTargetSize; selectionIsFull = false; }
public void GivenNull_ShouldThrow() { //arrange var card = CardBuilder.Create() .Build(); //act //assert Expect(() => card.StartJourney(null)) .To.Throw <ArgumentNullException>() .With.Property(err => err.ParamName) .Equal.To("station"); }
public void GivenStation_SetsCurrentJourneyStartFrom() { //arrange var station = StationBuilder.Create() .Build(); var card = CardBuilder.Create() .Build(); //act card.StartJourney(station); //assert Expect(card.CurrentJourneyStartFrom).To.Not.Be.Null(); Expect(card.CurrentJourneyStartFrom).To.Equal(station); }
public void GivenSameStationAsJourneyStart_ReturnsNull() { //arrange var stationFrom = StationBuilder.Create() .Build(); var card = CardBuilder.Create() .Build(); //act card.StartJourney(stationFrom); var actual = card.EndJourney(stationFrom); //assert Expect(actual).To.Be.Null(); }
private static Journey CreateSingleJourneyWithZoneCost(decimal from, decimal to) { var stationFrom = StationBuilder.Create() .WithZoneWithCostPerSingleJourney(from) .Build(); var stationTo = StationBuilder.Create() .WithZoneWithCostPerSingleJourney(to) .Build(); var card = CardBuilder.Create() .Build(); card.StartJourney(stationFrom); return(card.EndJourney(stationTo)); }
public void GivenStation_WithJourneyUnderway_ClearsCurrentJourneyStartFrom() { //arrange var stationTo = StationBuilder.Create() .Build(); var stationFrom = StationBuilder.Create() .Build(); var card = CardBuilder.Create() .Build(); //act card.StartJourney(stationFrom); card.EndJourney(stationTo); //assert Expect(card.CurrentJourneyStartFrom).To.Be.Null(); }
public void GivenStation_WithJourneyUnderway_ReturnsJourney() { //arrange var stationTo = StationBuilder.Create() .Build(); var stationFrom = StationBuilder.Create() .Build(); var card = CardBuilder.Create() .Build(); //act card.StartJourney(stationFrom); var actual = card.EndJourney(stationTo); //assert Expect(actual).To.Not.Be.Null(); }
public void GivenStation_WithJourneyUnderway_AddsJourneyToHistory() { //arrange var stationTo = StationBuilder.Create() .Build(); var stationFrom = StationBuilder.Create() .Build(); var card = CardBuilder.Create() .Build(); //act card.StartJourney(stationFrom); var actual = card.EndJourney(stationTo); //assert Expect(card.JourneyHistory.AsEnumerable()).To.Contain(actual); }
public void ReturnsJourney_WithCostNotExceedingCostPerWeekLimitOfMostExpensiveZone() { //arrange var costFirstJourney = 3m; var dateOfFirstJourney = new DateTime(2018, 8, 6); var expectedCostSecondJourney = 2m; var dateOfSecondJourney = dateOfFirstJourney.AddDays(7); var zone1 = FakeZoneBuilder .Create() .WithCostPerSingleJourney(3) .WithCostPerMonthLimit(4) .Build(); var zone2 = FakeZoneBuilder .Create() .WithCostPerSingleJourney(4) .WithCostPerMonthLimit(5) .Build(); var firstJourney = JourneyBuilder.Create() .WithCost(costFirstJourney) .WithDate(dateOfFirstJourney) .Build(); var card = CardBuilder.Create() .WithJourneyHistory(firstJourney) .WithDateTimeProviderFor(dateOfSecondJourney) .Build(); var stationStart = StationBuilder.Create() .WithZone(zone1) .Build(); var stationEnd = StationBuilder.Create() .WithZone(zone2) .Build(); //act card.StartJourney(stationStart); var actual = card.EndJourney(stationEnd); //assert Expect(actual.Cost).To.Equal(expectedCostSecondJourney); }
public void ShouldReturnJourney_WithCostNotExceedingCostPerMonthLimitOfZone() { //arrange var costPerJourney = 2.5m; var dateOfFirstJourney = new DateTime(2018, 8, 6); var costFirstJourney = 18m; var limitPerDay = 4.5m; var limitPerWeek = 10m; var limitPerMonth = 20m; var dateOfSecondJourney = dateOfFirstJourney.AddDays(7); var expectedCostSecondJourney = 2m; var firstJourney = JourneyBuilder.Create() .WithDate(dateOfFirstJourney) .WithCost(costFirstJourney) .Build(); var card = CardBuilder.Create() .WithDateTimeProviderFor(dateOfSecondJourney) .WithJourneyHistory(firstJourney) .Build(); var zone = FakeZoneBuilder .Create() .WithCostPerSingleJourney(costPerJourney) .WithCostPerDayLimit(limitPerDay) .WithCostPerWeekLimit(limitPerWeek) .WithCostPerMonthLimit(limitPerMonth) .Build(); var stationStart = StationBuilder.Create() .WithZone(zone) .Build(); var stationEnd = StationBuilder.Create() .WithZone(zone) .Build(); //act card.StartJourney(stationStart); var actual = card.EndJourney(stationEnd); //assert Expect(actual.Cost).To.Equal(expectedCostSecondJourney); }
public void GivenSecondJourneyNotInSameDayOrWeekAsFirst_WithCostBelowMonthMax_ShouldReturnJourney_WithFullCostOfSingleJourney() { //arrange var costPerJourney = 2.5m; var limitPerDay = 4.5m; var limitPerWeek = 4.5m; var dateOfFirstJourney = new DateTime(2018, 8, 6); var costFirstJourney = costPerJourney; var dateOfSecondJourney = dateOfFirstJourney.AddDays(7); var expectedCostSecondJourney = costPerJourney; var firstJourney = JourneyBuilder.Create() .WithDate(dateOfFirstJourney) .WithCost(costFirstJourney) .Build(); var card = CardBuilder.Create() .WithDateTimeProviderFor(dateOfSecondJourney) .WithJourneyHistory(firstJourney) .Build(); var zone = FakeZoneBuilder .Create() .WithCostPerSingleJourney(costPerJourney) .WithCostPerDayLimit(limitPerDay) .WithCostPerWeekLimit(limitPerWeek) .Build(); var stationStart = StationBuilder.Create() .WithZone(zone) .Build(); var stationEnd = StationBuilder.Create() .WithZone(zone) .Build(); //act card.StartJourney(stationStart); var actual = card.EndJourney(stationEnd); //assert Expect(actual.Cost).To.Equal(expectedCostSecondJourney); }
public void GivenStation_WithJourneyUnderway_ReturnsJourneyWithDate() { //arrange var today = new DateTime(2018, 8, 12, 13, 14, 15); var stationTo = StationBuilder.Create() .Build(); var stationFrom = StationBuilder.Create() .Build(); var card = CardBuilder.Create() .WithDateTimeProviderFor(today) .Build(); //act card.StartJourney(stationFrom); var actual = card.EndJourney(stationTo); //assert Expect(actual.Date).To.Equal(today); }
public void ReturnsJourney_WithCostNotExceedingCostPerDayLimitOfMostExpensiveZone() { //arrange var costFirstJourney = 3m; var expectedCostSecondJourney = 2m; var zone1 = FakeZoneBuilder .Create() .WithCostPerSingleJourney(3) .WithCostPerDayLimit(4) .Build(); var zone2 = FakeZoneBuilder .Create() .WithCostPerSingleJourney(4) .WithCostPerDayLimit(5) .Build(); var firstJourney = JourneyBuilder.Create() .WithCost(costFirstJourney) .Build(); var card = CardBuilder.Create() .WithJourneyHistory(firstJourney) .Build(); var stationStart = StationBuilder.Create() .WithZone(zone1) .Build(); var stationEnd = StationBuilder.Create() .WithZone(zone2) .Build(); //act card.StartJourney(stationStart); var actual = card.EndJourney(stationEnd); //assert Expect(actual.Cost).To.Equal(expectedCostSecondJourney); }
public void GivenSecondJourneyInSameMonth_ButNotSameYear_ShouldReturnJourney_WithFullCostOfSingleJourney() { //arrange var costPerJourney = 2.5m; var costFirstJourney = 18m; var limitPerMonth = 20m; var dateOfFirstJourney = new DateTime(2017, 1, 1); var dateOfSecondJourney = dateOfFirstJourney.AddYears(1); var expectedCostSecondJourney = costPerJourney; var firstJourney = JourneyBuilder.Create() .WithDate(dateOfFirstJourney) .WithCost(costFirstJourney) .Build(); var card = CardBuilder.Create() .WithDateTimeProviderFor(dateOfSecondJourney) .WithJourneyHistory(firstJourney) .Build(); var zone = FakeZoneBuilder .Create() .WithCostPerSingleJourney(costPerJourney) .WithCostPerMonthLimit(limitPerMonth) .Build(); var stationStart = StationBuilder.Create() .WithZone(zone) .Build(); var stationEnd = StationBuilder.Create() .WithZone(zone) .Build(); //act card.StartJourney(stationStart); var actual = card.EndJourney(stationEnd); //assert Expect(actual.Cost).To.Equal(expectedCostSecondJourney); }