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); }
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); }); }