public void ensure_number_of_houses_is_3()
        {
            _streetSpecificationReader = Substitute.For <IStreetSpecificationReader>();
            _streetSpecificationReader.LoadFile().Returns(new[] { 1, 2, 3 });

            GivenATownPlanner();

            _townPlanner.NumberOfHousesInStreet().ShouldBe(3);
        }
        public void ensure_houses_on_south_side_is_1()
        {
            _streetSpecificationReader = Substitute.For <IStreetSpecificationReader>();
            _streetSpecificationReader.LoadFile().Returns(new[] { 1, 2, 3, 5 });

            GivenATownPlanner();

            _townPlanner.NumberOfHousesOnSouthSide().ShouldBe(1);
        }
        public void ensure_duplciates_invalidate_specification()
        {
            _streetSpecificationReader = Substitute.For <IStreetSpecificationReader>();
            _streetSpecificationReader.LoadFile().Returns(new[] { 1, 2, 3, 4, 4 });

            GivenATownPlanner();

            _townPlanner.IsValid().ShouldBeFalse();
        }
        public void ensure_converts_to_houses_loads_street_specification()
        {
            _streetSpecificationReader = Substitute.For <IStreetSpecificationReader>();
            _streetSpecificationReader.LoadFile().Returns(new[] { 1, 2, 3, 4 });

            GivenATownPlanner();

            _townPlanner.GetHousesWestToEast().Count().ShouldBe(4);
        }
        public void ensure_south_side_houses_loads_street_specification()
        {
            _streetSpecificationReader = Substitute.For <IStreetSpecificationReader>();
            _streetSpecificationReader.LoadFile().Returns(new[] { 1, 2, 3, 4 });

            GivenATownPlanner();

            _townPlanner.SouthSideHouses().Count().ShouldBe(2);
        }
Esempio n. 6
0
        public void ensure_reset_crossings_between_calls()
        {
            _streetSpecificationReader = Substitute.For <IStreetSpecificationReader>();

            _streetSpecificationReader.LoadFile().Returns(new[] {
                1, 2, 4, 3, 5, 6, 7, 8, 9, 10
            });

            GivenARoutePlanner();

            _routeplanner.GetDeliveryByNorthSideThenSouthSide();
            _routeplanner.GetDeliveryByEachhouseInTurnWestToEast();

            _routeplanner.TotalRoadCrossing().ShouldBe(7);
        }
Esempio n. 7
0
        public void ensure_delivery_to_each_house_in_turn_from_west_to_east_meets_provided_order()
        {
            var expected = new[] { 1, 2, 4, 3, 5, 6, 7, 8, 9, 10 };

            _streetSpecificationReader = Substitute.For <IStreetSpecificationReader>();

            _streetSpecificationReader.LoadFile().Returns(new[] {
                1, 2, 4, 3, 5, 6, 7, 8, 9, 10
            });

            GivenARoutePlanner();

            var actual = _routeplanner.GetDeliveryByEachhouseInTurnWestToEast();

            _routeplanner.TotalRoadCrossing().ShouldBe(7);
            actual.ShouldBe(expected);
        }
Esempio n. 8
0
        public void ensure_west_to_east_meets_provided_order()
        {
            var expected = new[] { 1, 3, 5, 7, 9, 10, 8, 6, 4, 2 };

            _streetSpecificationReader = Substitute.For <IStreetSpecificationReader>();

            _streetSpecificationReader.LoadFile().Returns(new[] {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            });

            GivenARoutePlanner();

            var actual = _routeplanner.GetDeliveryByNorthSideThenSouthSide();

            _routeplanner.TotalRoadCrossing().ShouldBe(1);
            actual.ShouldBe(expected);
        }
 public static TownPlanner Create(IStreetSpecificationReader reader)
 {
     return(new TownPlanner(reader));
 }
Esempio n. 10
0
 private TownPlanner(IStreetSpecificationReader reader)
 {
     _reader = reader;
 }
 private static void GivenAValidStreetSpecification()
 {
     _streetSpecificationReader = Substitute.For <IStreetSpecificationReader>();
     _streetSpecificationReader.LoadFile().Returns(new[] { 1, 2, 3 });
 }
 private static void GivenAInvalidFileStartsFrom2()
 {
     _streetSpecificationReader = Substitute.For <IStreetSpecificationReader>();
     _streetSpecificationReader.LoadFile().Returns(new[] { 2 });
 }