示例#1
0
 public void ShouldNotThrow()
 {
     //arrange
     //act
     //assert
     Expect(() => CardBuilder.Create().Build())
     .To.Not.Throw();
 }
示例#2
0
 public void GivenNullJourneyHistory_ShouldThrow()
 {
     //arrange
     //act
     //assert
     Expect(() => CardBuilder.Create().WithNullJourneyHistory().Build())
     .To.Throw <ArgumentNullException>()
     .With.Property(err => err.ParamName)
     .Equal.To("journeyHistory");;
 }
示例#3
0
 public void GivenNullDateTimeProvider_ShouldThrow()
 {
     //arrange
     //act
     //assert
     Expect(() => CardBuilder.Create().WithNullDateTimeProvider().Build())
     .To.Throw <ArgumentNullException>()
     .With.Property(err => err.ParamName)
     .Equal.To("dateTimeProvider");;
 }
示例#4
0
            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>();
            }
示例#5
0
        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;
        }
示例#6
0
            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");
            }
示例#7
0
            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);
            }
示例#8
0
            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();
            }
示例#9
0
                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));
                }
示例#10
0
            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();
            }
示例#11
0
            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();
            }
示例#12
0
            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);
            }
示例#13
0
                        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);
                        }
示例#14
0
                        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);
                        }
示例#15
0
                        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);
                        }
示例#16
0
            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);
            }
示例#17
0
                        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);
                        }
示例#18
0
                        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);
                        }