public void GetNewsPapersDeliveryOrderTest()
        {
            IStreetSpecifications specficationTest1   = new FileStreetSpecifications("13245.txt");
            NewsPapersDeliveryNorthSouthApproach test = new NewsPapersDeliveryNorthSouthApproach(specficationTest1);

            int[] expected = { 1, 3, 5, 4, 2 };
            int[] actual   = test.GetNewsPapersDeliveryOrder();

            Assert.AreEqual(expected.Length, actual.Length);

            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }

            specficationTest1 = new FileStreetSpecifications("Street1.txt");
            test = new NewsPapersDeliveryNorthSouthApproach(specficationTest1);

            expected = new[] { 1, 3, 5, 7, 9, 11, 13, 15, 12, 10, 8, 6, 4, 2 };
            actual   = test.GetNewsPapersDeliveryOrder();

            Assert.AreEqual(expected.Length, actual.Length);

            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
        public void GetCrossingStreetNumberTest()
        {
            IStreetSpecifications specficationTest1    = new FileStreetSpecifications("13245.txt");
            NewsPaperDeliveryHouseByHouseApproach test = new NewsPaperDeliveryHouseByHouseApproach(specficationTest1);

            Assert.AreEqual(2, test.GetCrossingStreetNumber());
            specficationTest1 = new FileStreetSpecifications("Street1.txt");

            test = new NewsPaperDeliveryHouseByHouseApproach(specficationTest1);
            Assert.AreEqual(8, test.GetCrossingStreetNumber());
        }
Example #3
0
        public void TestGetStreetHouses()
        {
            FileStreetSpecifications test = new FileStreetSpecifications("13245.txt");

            Assert.AreEqual(5, test.GetStreetHouses().Length);
            Assert.AreEqual(5, test.GetStreetHouses().Length);

            test = new FileStreetSpecifications("Street1.txt");
            Assert.AreEqual(14, test.GetStreetHouses().Length);

            test = new FileStreetSpecifications("Invalid1.txt");
            Assert.AreEqual(8, test.GetStreetHouses().Length);
        }
        public void NumberOfNorthHousesTest()
        {
            IStreetSpecifications specficationTest1 = new FileStreetSpecifications("13245.txt");

            TownPlannerStreetTracker test = new TownPlannerStreetTracker(specficationTest1);

            Assert.AreEqual(3, test.NumberOfNorthHouses());

            specficationTest1 = new FileStreetSpecifications("Street1.txt");

            test = new TownPlannerStreetTracker(specficationTest1);
            Assert.AreEqual(8, test.NumberOfNorthHouses());

            specficationTest1 = new FileStreetSpecifications("Invalid1.txt");

            test = new TownPlannerStreetTracker(specficationTest1);

            try
            {
                test.NumberOfNorthHouses();
                Assert.Fail("Must throw exception");
            }
            catch (Exception)
            {
                // ignored
            }

            specficationTest1 = new FileStreetSpecifications("Invalid1.txt");

            test = new TownPlannerStreetTracker(specficationTest1);

            try
            {
                test.NumberOfNorthHouses();
                Assert.Fail("Must throw exception");
            }
            catch (Exception)
            {
                // ignored
            }
        }
Example #5
0
        static void Main()
        {
            IStreetSpecifications streetSpecifications = new FileStreetSpecifications("Street1.txt");
            IStreetTracker        defaultTracker       = new TownPlannerStreetTracker(streetSpecifications);

            System.Console.WriteLine("Story 1");
            System.Console.WriteLine("-------\n");

            var isFileValid = defaultTracker.IsValidStreet()
                        ? "The Specifications are valid."
                        : "The Specifications are not valid.";

            System.Console.WriteLine("Acceptance Criteria 1: " + isFileValid + "\n");

            System.Console.WriteLine("Acceptance Criteria 2: The number of houses in a given street are : " + defaultTracker.NumberOfHouses());

            System.Console.WriteLine("\nAcceptance Criteria 3: The number of houses on the left hand (north) side of the street are : " + defaultTracker.NumberOfNorthHouses());
            System.Console.WriteLine("\nAcceptance Criteria 4: The number of houses on the right hand (south) side of the street are : " + defaultTracker.NumberOfSouthHouses());

            System.Console.WriteLine("\n-------------------------------------------------------------------------------\n");

            System.Console.WriteLine("Story 2");
            System.Console.WriteLine("-------\n");

            NewsPapersDeliveryNorthSouthApproach delivery1 = new NewsPapersDeliveryNorthSouthApproach(streetSpecifications);

            NewsPaperDeliveryHouseByHouseApproach delivery2 = new NewsPaperDeliveryHouseByHouseApproach(streetSpecifications);

            System.Console.WriteLine(
                "\nAcceptance Criteria 5: The list of house numbers in the order that I will be delivering to, so that I can sort by satchel in advance are :" +
                delivery1.GetNewsPapersDeliveryOrder().Aggregate("\n\t", (rslt, x) => rslt + " " + x, x => x));

            System.Console.WriteLine(delivery2.GetNewsPapersDeliveryOrder().Aggregate("\t", (rslt, x) => rslt + " " + x, x => x));

            System.Console.WriteLine("\nAcceptance Criteria 6: (" + delivery2.GetCrossingStreetNumber() + ") times I will have to cross the road from one side to the other to make my deliveries");

            System.Console.ReadKey();
        }
        public void IsValidStreetTest()
        {
            IStreetSpecifications specficationTest1 = new FileStreetSpecifications("13245.txt");

            TownPlannerStreetTracker test = new TownPlannerStreetTracker(specficationTest1);

            Assert.IsTrue(test.IsValidStreet());
            Assert.IsTrue(test.IsValidStreet());

            specficationTest1 = new FileStreetSpecifications("Street1.txt");

            test = new TownPlannerStreetTracker(specficationTest1);
            Assert.IsTrue(test.IsValidStreet());

            specficationTest1 = new FileStreetSpecifications("Invalid1.txt");

            test = new TownPlannerStreetTracker(specficationTest1);
            Assert.IsFalse(test.IsValidStreet());

            specficationTest1 = new FileStreetSpecifications("Invalid2.txt");

            test = new TownPlannerStreetTracker(specficationTest1);
            Assert.IsFalse(test.IsValidStreet());
        }