Esempio n. 1
0
        public void SaveGraph_LoadGraph_ReturnsEqualGraph(
            int obstaclePercent, int[] graphParams)
        {
            graphAssembler = new GraphAssemble(
                vertexFactory,
                coordinateFactory,
                graphFactory,
                costFactory,
                radarFactory);

            IGraph deserialized;
            var    graph = graphAssembler.AssembleGraph(
                obstaclePercent, graphParams);
            var serializer = new GraphSerializer(
                formatter, vertexConverter, graphFactory);

            using (var stream = new MemoryStream())
            {
                serializer.SaveGraph(graph, stream);
                stream.Seek(0, SeekOrigin.Begin);
                deserialized = serializer.LoadGraph(stream);
            }

            Assert.AreEqual(graph, deserialized);
            Assert.AreNotSame(graph, deserialized);
        }
Esempio n. 2
0
 public GraphAssemblerTests()
 {
     coordinateFactory = new TestCoordinateFactory();
     vertexFactory     = new TestVertexFactory();
     costFactory       = new TestCostFactory();
     graphFactory      = new TestGraphFactory();
     radarFactory      = new CoordinateAroundRadarFactory();
     graphAssembler    = new GraphAssemble(vertexFactory,
                                           coordinateFactory, graphFactory, costFactory, radarFactory);
 }
Esempio n. 3
0
 public MainViewModel(
     BaseGraphFieldFactory fieldFactory,
     IVertexEventHolder eventHolder,
     IGraphSerializer graphSerializer,
     IGraphAssemble graphFactory,
     IPathInput pathInput,
     IAssembleClasses assembleClasses,
     Logs log)
     : base(fieldFactory, eventHolder, graphSerializer,
            graphFactory, pathInput, assembleClasses, log)
 {
 }
Esempio n. 4
0
        public AlgorithmTest()
        {
            radarFactory      = new CoordinateAroundRadarFactory();
            graphFactory      = new TestGraphFactory();
            vertexFactory     = new TestVertexFactory();
            costFactory       = new TestVertexCostFactory();
            coordinateFactory = new TestCoordinateFactory();

            graphAssemble = new GraphAssemble(vertexFactory,
                                              coordinateFactory,
                                              graphFactory,
                                              costFactory,
                                              radarFactory);

            testAssemble = new TestGraphAssemble(graphAssemble);
        }
Esempio n. 5
0
        protected MainModel(BaseGraphFieldFactory fieldFactory,
                            IVertexEventHolder eventHolder,
                            IGraphSerializer graphSerializer,
                            IGraphAssemble graphAssembler,
                            IPathInput pathInput,
                            IAssembleClasses assembleClasses,
                            ILog log)
        {
            this.eventHolder = eventHolder;
            serializer       = graphSerializer;
            graphSerializer.OnExceptionCaught += log.Warn;
            this.fieldFactory    = fieldFactory;
            this.graphAssembler  = graphAssembler;
            this.pathInput       = pathInput;
            this.assembleClasses = assembleClasses;
            this.log             = log;

            Graph = new NullGraph();
        }
        public GraphPathTests()
        {
            graphAssemble = new TestGraph2DAssemble();
            expectedPraphPathCoordinates = new ICoordinate[]
            {
                new TestCoordinate(0, 0), //1
                new TestCoordinate(0, 1), //5
                new TestCoordinate(1, 2), //8
                new TestCoordinate(1, 3), //1
                new TestCoordinate(2, 4), //3
                new TestCoordinate(3, 5), //2
                new TestCoordinate(3, 6), //1
                new TestCoordinate(4, 7)  //5
            };
            graph = graphAssemble.AssembleGraph(0);
            var source = graph[expectedPraphPathCoordinates.First()];
            var target = graph[expectedPraphPathCoordinates.Last()];

            endPoints      = new EndPoints(source, target);
            parentVertices = new ParentVertices();
            FormParentVertices(parentVertices);
        }
Esempio n. 7
0
        public void SaveGraph_LoadGraph_NotSerializableCoordinate_ThrowsCantSerializeGraphException(
            int obstaclePercent, int[] graphParams)
        {
            graphAssembler = new GraphAssemble(
                vertexFactory,
                notSerializableCoordinateFactory,
                graphFactory,
                costFactory,
                radarFactory);

            var graph = graphAssembler.AssembleGraph(
                obstaclePercent, graphParams);
            var serializer = new GraphSerializer(
                formatter, vertexConverter, graphFactory);

            Assert.Throws <CantSerializeGraphException>(() =>
            {
                using var stream = new MemoryStream();
                serializer.SaveGraph(graph, stream);
                stream.Seek(0, SeekOrigin.Begin);
                serializer.LoadGraph(stream);
            });
        }
Esempio n. 8
0
 public GraphCreatingViewModel(ILog log, IMainModel model, IGraphAssemble graphFactory)
     : base(log, model, graphFactory)
 {
 }
Esempio n. 9
0
 protected GraphCreatingModel(ILog log, IMainModel model, IGraphAssemble graphFactory)
 {
     this.model        = model;
     this.graphFactory = graphFactory;
     this.log          = log;
 }
Esempio n. 10
0
 public TestGraphAssemble(IGraphAssemble graphAssemble)
 {
     this.graphAssemble = graphAssemble;
 }
Esempio n. 11
0
 public GraphCreatingViewModel(ILog log, IMainModel model, IGraphAssemble graphFactory)
     : base(log, model, graphFactory)
 {
     ConfirmCreateGraphCommand = new RelayCommand(ExecuteConfirmCreateGraphCommand);
     CancelCreateGraphCommand  = new RelayCommand(obj => CloseWindow());
 }