public void SolverProblem_DFSFringeOverrideInitialState_CorrectResult()
        {
            var solver = new ProblemSolver <ShipProblemData>();

            //This problem is a sub-problem of the original problem
            var myData = new ShipProblemData();

            myData.CurrentPath.Push(Ports.Port1);

            var book = new Stack <string>();

            book.Push(Ports.Port2);
            book.Push(Ports.Port1);
            book.Push(Ports.Port3);
            myData.Ports[Ports.Port1] = book;

            book = new Stack <string>();

            book.Push(Ports.Port3);
            book.Push(Ports.Port1);
            book.Push(Ports.Port1);
            myData.Ports[Ports.Port2] = book;

            book = new Stack <string>();

            book.Push(Ports.Port2);
            book.Push(Ports.Port3);
            book.Push(Ports.Port2);
            myData.Ports[Ports.Port3] = book;

            var summary = solver.SolveProblem(new DFSFringe <ShipProblemData>(), new ShipProblem(),
                                              new Config {
                DataForInitialState = myData
            });

            Assert.IsTrue(summary.MaxNumberOfStates == 3);
            Assert.IsTrue(summary.TotalNumberOfStates == 18);

            Assert.IsNotNull(summary);
            Assert.IsTrue(summary.Results.Count == 1);
            Assert.IsTrue(summary.Results[0].Data != null);
            Assert.IsTrue(summary.Results[0].Data.Count == 10);
            Assert.IsTrue(summary.Results[0].Data[0].CurrentPath != null);
            Assert.IsTrue(summary.Results[0].Data[0].CurrentPath.Count == 10);

            Assert.IsTrue(summary.Results[0].Data[0].Ports.All(p => p.Value.Count == 0));
            var pathAsList = summary.Results[0].Data[0].CurrentPath.ToList();
            var lastPort   = pathAsList.Last();

            for (var i = 0; i < pathAsList.Count; ++i)
            {
                Assert.IsTrue(pathAsList[i] == Solutions[lastPort][i]);
            }
        }
        public ShipProblemData Clone()
        {
            var state = new ShipProblemData();

            foreach (var pair in Ports)
            {
                var stack = new Stack <string>();
                foreach (var target in pair.Value.Reverse())
                {
                    stack.Push(target);
                }

                state.Ports[pair.Key] = stack;
            }

            foreach (var item in CurrentPath.Reverse())
            {
                state.CurrentPath.Push(item);
            }

            return(state);
        }