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_house_count_is_zero_when_street_specification_not_loaded()
        {
            _townPlanner = TownPlanner.Create(_streetSpecificationReader);

            _townPlanner.NorthSideHouses().Count().ShouldBe(0);
            _townPlanner.IsValid().ShouldBeFalse();
            _townPlanner.GetHousesWestToEast().Count.ShouldBe(0);
            _townPlanner.SouthSideHouses().Count().ShouldBe(0);
            _townPlanner.NumberOfHousesInStreet().ShouldBe(0);
            _townPlanner.NumberOfHousesOnNorthSide().ShouldBe(0);
            _townPlanner.NumberOfHousesOnSouthSide().ShouldBe(0);
        }
Exemple #3
0
        public IEnumerable <int> GetDeliveryByEachhouseInTurnWestToEast()
        {
            ResetCrossings();
            var houses              = _townplanner.GetHousesWestToEast();
            var deliveryOrder       = new List <int>();
            var currentSideOfStreet = StreetSide.North;

            while (houses.Count > 0)
            {
                var house = houses.Dequeue();
                if (house != null)
                {
                    if (currentSideOfStreet != house.SideOfStreet)
                    {
                        UpdateCrossing();
                        currentSideOfStreet = house.SideOfStreet;
                    }

                    deliveryOrder.Add(house.Number);
                }
            }

            return(deliveryOrder);
        }