Exemple #1
0
        public void GossipingBusDriversExchangeAllGossipsAfter(string fileName, int expectedMinutes)
        {
            //arrange
            void OnSuccess(int minute) => Assert.Equal(expectedMinutes, minute);
            void OnFailure() => FailedTest();

            BusDrivers busDrivers = GossipingBusDriversInputReader.ReadDriversFrom(fileName);

            //act
            GossipingBusDriversAlgorithm.SolveForInput(busDrivers, OnSuccess, OnFailure);

            //assert
        }
Exemple #2
0
        public void GossipingBusDriversNeverExchangeAllGossips()
        {
            //arrange
            void OnSuccess(int minute) => FailedTest();
            void OnFailure() => SuccessfulTest();

            BusDrivers busDrivers = GossipingBusDriversInputReader.ReadDriversFrom("InputTextData\\Example2.txt");

            //act
            GossipingBusDriversAlgorithm.SolveForInput(busDrivers, OnSuccess, OnFailure);

            //assert
        }
Exemple #3
0
        static void Main()
        {
            void OnSuccess(int minute) => Console.WriteLine("All bus drivers have found out all gossips after " + minute + " minutes");
            void OnFailure() => Console.WriteLine("never");

            string[] fileNames = { "InputTextData\\Example1.txt", "InputTextData\\Example2.txt", "InputTextData\\Challenge1.txt", "InputTextData\\Challenge2.txt" };

            foreach (var fileName in fileNames)
            {
                BusDrivers busDrivers = GossipingBusDriversInputReader.ReadDriversFrom(fileName);
                GossipingBusDriversAlgorithm.SolveForInput(busDrivers, OnSuccess, OnFailure);
            }
        }