public void TestAdventure_ThrowsOverflow_OnTooLongTimespan()
        {
            SeedData();

            _adventureData.Hikers.Add(new Hiker {
                Name = "Hiker E", Speed = .1, StartingLocation = 0
            });
            _adventureData.Hikers.Add(new Hiker {
                Name = "Hiker F", Speed = 999, StartingLocation = 2
            });
            _adventureData.Hikers.Add(new Hiker {
                Name = "Hiker G", Speed = 200000, StartingLocation = 1
            });
            _adventureData.Hikers.Add(new Hiker {
                Name = "Hiker H", Speed = 1, StartingLocation = 3
            });
            _adventureData.Hikers.Add(new Hiker {
                Name = "Hiker I", Speed = 33, StartingLocation = 4
            });
            _adventureData.Hikers.Add(new Hiker {
                Name = "Hiker J", Speed = 99999, StartingLocation = 1
            });
            _adventureData.Hikers.Add(new Hiker {
                Name = "Hiker K", Speed = 555, StartingLocation = 2
            });
            _adventureData.Hikers.Add(new Hiker {
                Name = "Hiker L", Speed = 110, StartingLocation = 4
            });

            _adventureData.Bridges.Add(new Bridge {
                Location = 4, Length = 99999999999999999
            });
            _adventureData.Bridges.Add(new Bridge {
                Location = 5, Length = 666666666666
            });
            _adventureData.Bridges.Add(new Bridge {
                Location = 6, Length = 4444444444444
            });
            _adventureData.Bridges.Add(new Bridge {
                Location = 7, Length = 66666666
            });
            _adventureData.Bridges.Add(new Bridge {
                Location = 8, Length = .1
            });
            _adventureData.Bridges.Add(new Bridge {
                Location = 9, Length = 1111
            });
            _adventureData.Bridges.Add(new Bridge {
                Location = 10, Length = 99999
            });

            Adventure         currentAdventure  = new Adventure(_adventureData);
            AdventureObserver adventureObserver = new AdventureObserver(currentAdventure);

            currentAdventure.Attach(adventureObserver);

            Assert.Throws <System.OverflowException>(() => currentAdventure.Start());
        }
        public void TestAdventure_EmptyData_ThrowsException()
        {
            Adventure         currentAdventure  = new Adventure(_adventureData);
            AdventureObserver adventureObserver = new AdventureObserver(currentAdventure);

            currentAdventure.Attach(adventureObserver);

            Assert.Throws <System.ArgumentNullException>(() => currentAdventure.Start());
        }
        public void TestAdventureFinishes_WithObserver()
        {
            SeedData();

            Adventure         currentAdventure  = new Adventure(_adventureData);
            AdventureObserver adventureObserver = new AdventureObserver(currentAdventure);

            currentAdventure.Attach(adventureObserver);
            currentAdventure.Start();

            Assert.IsTrue(currentAdventure.IsFinished);
        }
        public void TestAdventure_HikerWithNegativeSpeed_ThrowsException()
        {
            SeedData();
            _adventureData.Hikers.Add(new Hiker {
                Name = "Hiker I", Speed = -1, StartingLocation = 4
            });

            Adventure         currentAdventure  = new Adventure(_adventureData);
            AdventureObserver adventureObserver = new AdventureObserver(currentAdventure);

            currentAdventure.Attach(adventureObserver);

            Assert.Throws <System.ArgumentException>(() => currentAdventure.Start());
        }
        public void TestAdventure_HikersNull_ThrowsException()
        {
            _adventureData.Bridges = new List <Bridge>();
            _adventureData.Bridges.Add(new Bridge {
                Location = 1, Length = 100
            });

            Adventure         currentAdventure  = new Adventure(_adventureData);
            AdventureObserver adventureObserver = new AdventureObserver(currentAdventure);

            currentAdventure.Attach(adventureObserver);

            Assert.Throws <System.ArgumentNullException>(() => currentAdventure.Start());
        }
        public void TestAdventure_Bridges_MultipleBridgesInSameLocation_ThrowsExeption()
        {
            SeedData();

            _adventureData.Bridges.Add(new Bridge {
                Location = 1, Length = 44444
            });
            Adventure         currentAdventure  = new Adventure(_adventureData);
            AdventureObserver adventureObserver = new AdventureObserver(currentAdventure);

            currentAdventure.Attach(adventureObserver);

            Assert.Throws <System.ArgumentException>(() => currentAdventure.Start());
        }
        public void TestAdventure_Bridges_BridgesNull_ThrowsExeption()
        {
            _adventureData.Hikers = new List <Hiker>();
            _adventureData.Hikers.Add(new Hiker {
                Name = "Hiker A", Speed = 10, StartingLocation = 0
            });

            Adventure         currentAdventure  = new Adventure(_adventureData);
            AdventureObserver adventureObserver = new AdventureObserver(currentAdventure);

            currentAdventure.Attach(adventureObserver);

            Assert.Throws <System.ArgumentNullException>(() => currentAdventure.Start());
        }
        public void TestAdventure_NoHikersAtStartingLocation_ThrowsException()
        {
            _adventureData.Bridges = new List <Bridge>();
            _adventureData.Bridges.Add(new Bridge {
                Location = 1, Length = 100
            });

            _adventureData.Hikers = new List <Hiker>();
            _adventureData.Hikers.Add(new Hiker {
                Name = "Hiker I", Speed = 33, StartingLocation = 4
            });

            Adventure         currentAdventure  = new Adventure(_adventureData);
            AdventureObserver adventureObserver = new AdventureObserver(currentAdventure);

            currentAdventure.Attach(adventureObserver);

            Assert.Throws <System.ArgumentException>(() => currentAdventure.Start());
        }
        static void Main(string[] args)
        {
            //Instructions:
            //Write a C# program that simulates a team hiking through a forest at night.
            //The team encounters a series of narrow bridges along the way. At each bridge they may meet additional hikers who need their help to cross the bridge.

            //The narrow bridge can only hold two people at a time.
            //They have one torch and because it's night, the torch has to be used when crossing the bridge.
            //Each hiker can cross the bridge at different speeds. When two hikers cross the bridge together, they must move at the slower person's pace.
            //Determine the fastest time that the hikers can cross each bridge and the total time for all crossings.
            //The input to the program will be a yaml file that describes the speeds of each person, the bridges encountered, their length,
            //and the additional hikers encountered along the way.
            //Your solution should assume any number of people and bridges can be provided as inputs.

            //Demonstrate the operation of your program using the following inputs:
            //the hikers cross 3 bridges, at the first bridge(100 ft long)
            //4 hikers cross(hiker A can cross at 100 ft/minute, B at 50 ft/minute, C at 20 ft/minute, and D at 10 ft/minute),
            //at the second bridge(250 ft long) an additional hiker crosses with the team(E at 2.5 ft / minute),
            //and finally at the last bridge(150 ft long) two hikers are encountered(F at 25 ft / minute and G at 15 ft / minute).

            //You will be judged on the following:
            //Strategy(s) - there are several ways to solve the problem, you can provide more than one. The goal is to show us how you think.
            //Architecture and design - we want to see how well you architect and design solutions to complex problems.
            //Testing - we want to see how you approach testing of the solution.
            //Standards and best practices.
            //Explanation - as a C# thought leader in the organization you will be working with and mentoring other engineers. How well you can describe and explain your solution is very important.

            //Please provide a link to your git repo such as github or bitbucket with your solution.

            //I'm building the Adventure ata from the yaml file with a builder pattern.
            string inputFilePath = "./Data/Input.yaml";
            AdventureDataBuilder adventureDataBuilder = new AdventureDataBuilder(inputFilePath);

            adventureDataBuilder.Build();
            Adventure currentAdventure = new Adventure(adventureDataBuilder.GetAdventureData());
            //I'm using the observer pattern to fetch information about the adventure to log to the console to track progress.
            AdventureObserver adventureObserver = new AdventureObserver(currentAdventure);

            currentAdventure.Attach(adventureObserver);
            currentAdventure.Start();
        }