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]);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: D0tNetGeek/PaperRound
        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();
        }