public void CopyNetwork_Throws_If_InputNetwork_Is_Incorrect_Type()
        {
            //Arrange
            var copier = new BasicAdjListCopier();
            INetwork src = new DummyMatrix();

            var ex = Assert.Throws<ArgumentException>(() => copier.CopyNetwork(src));
        }
        public void CopyNetwork_Throws_If_InputNetwork_Is_Null()
        {
            //Arrange
            var copier = new BasicAdjListCopier();
            INetwork src = null;

            var ex = Assert.Throws<ArgumentNullException>(() => copier.CopyNetwork(src));
        }
        public void CopyNetwork_And_Exclude_Data_Attributes(int nodeCount, int edgeCount, bool directed)
        {
            //Arrange
            var copier = new BasicAdjListCopier();
            IBasicAdjList src = BasicAdjListGenerator.GenerateAdjList(nodeCount, edgeCount, directed);

            //Act
            IBasicAdjList net = copier.CopyNetwork(src) as IBasicAdjList;

            //Assert
            Assert.NotNull(net);
            Assert.Equal(net.NodeCount, src.NodeCount);
            Assert.Equal(net.Nodes.Count, src.NodeCount);
            Assert.Equal(net.EdgeCount, src.EdgeCount);
            Assert.Equal(net.Edges.Count, src.EdgeCount);
            Assert.Equal(net.IsDirected, src.IsDirected);
            Assert.Equal(net.Name, src.Name);
            Assert.NotEqual(net.Id, src.Id);
            Assert.Equal(src.NodeAttributeCount, src.NodeAttributeCount);
            Assert.Equal(src.EdgeAttributeCount, src.EdgeAttributeCount);
        }
        public void CopyNetwork_With_Edge_Data_Attributes(int testId, int numNodes, int numEdges, bool isDirected, bool selfLoops, bool multiEdges, int[] intVals, double[] doubleVals, bool[] boolVals, string[] stringVals)
        {
            //Arrange
            var copier = new BasicAdjListCopier();
            IBasicAdjList src = BasicAdjListGenerator.GenerateAdjListWithDataAttribs(numNodes, numEdges, isDirected, false, true);
            var builder = new DataAttributesBuilder();
            var colIndex = builder.AddColumn((IEdgeAttributes)src, typeof(int));
            builder.PopulateCol<int, IEdge>(src.EdgeData, colIndex, intVals);
            colIndex = builder.AddColumn((IEdgeAttributes)src, typeof(double));
            builder.PopulateCol<double, IEdge>(src.EdgeData, colIndex, doubleVals);
            colIndex = builder.AddColumn((IEdgeAttributes)src, typeof(bool));
            builder.PopulateCol<bool, IEdge>(src.EdgeData, colIndex, boolVals);
            colIndex = builder.AddColumn((IEdgeAttributes)src, typeof(string));
            builder.PopulateCol<string, IEdge>(src.EdgeData, colIndex, stringVals);

            copier.CopyNodeData = false;
            copier.CopyEdgeData = true;
            IBasicAdjList net = copier.CopyNetwork(src) as IBasicAdjList;

            Assert.NotNull(net);
            Assert.Equal(net.EdgeCount, src.EdgeCount);
            Assert.Equal(net.Edges.Count, src.EdgeCount);
            Assert.Equal(net.EdgeCount, src.EdgeCount);
            Assert.Equal(net.Edges.Count, src.EdgeCount);
            Assert.Equal(net.IsDirected, src.IsDirected);
            Assert.Equal(net.Name, src.Name);
            Assert.NotEqual(net.Id, src.Id);

            Assert.NotNull(net.EdgeData);
            Assert.Equal(4, net.EdgeData.ColumnCount);
            Assert.Equal(numEdges, net.EdgeData.RowCount);

            //--
            Assert.Equal(typeof(int), net.EdgeData.DataTypes[0]);
            //--
            Assert.Equal(typeof(double), net.EdgeData.DataTypes[1]);
            //--
            Assert.Equal(typeof(bool), net.EdgeData.DataTypes[2]);
            //--
            Assert.Equal(typeof(string), net.EdgeData.DataTypes[3]);

            object objVal = null;

            //-- ints

            var list0 = net.EdgeData.GetColumnData<int>(0); ;
            int intVal = -1;
            for (int i = 0; i < list0.Count; i++)
            {
                objVal = list0[i];
                Assert.NotNull(objVal);
                Assert.IsType(typeof(int), objVal);
                intVal = (int)objVal;
                Assert.Equal(intVals[i], intVal);
            }

            //-- doubles
            var list1 = net.EdgeData.GetColumnData<double>(1);
            double doubleVal = -1.1;
            for (int i = 0; i < list1.Count; i++)
            {
                objVal = list1[i];
                Assert.NotNull(objVal);
                Assert.IsType(typeof(double), objVal);
                doubleVal = (double)objVal;
                Assert.Equal(doubleVals[i], doubleVal);
            }

            //-- bools
            var list2 = net.EdgeData.GetColumnData<bool>(2);
            bool boolVal = false;
            for (int i = 0; i < list2.Count; i++)
            {
                objVal = list2[i];
                Assert.NotNull(objVal);
                Assert.IsType(typeof(bool), objVal);
                boolVal = (bool)objVal;
                Assert.Equal(boolVals[i], boolVal);
            }

            //-- strings
            var list3 = net.EdgeData.GetColumnData<string>(3);
            string stringVal = null;
            for (int i = 0; i < list3.Count; i++)
            {
                objVal = list3[i];
                Assert.NotNull(objVal);
                Assert.IsType(typeof(string), objVal);
                stringVal = (string)objVal;
                Assert.Equal(stringVals[i], stringVal);
            }
        }
        public void CopyNetwork_With_Node_Data_Attributes_With_Null_In_Attribs(int testId, int numNodes, int numEdges, bool isDirected, bool selfLoops, bool multiEdges, string[] stringVals)
        {
            //Arrange
            var copier = new BasicAdjListCopier();
            IBasicAdjList src = BasicAdjListGenerator.GenerateAdjListWithDataAttribs(numNodes, numEdges, isDirected, true, false);
            var builder = new DataAttributesBuilder();
            var colIndex = builder.AddColumn((INodeAttributes)src, typeof(string));
            builder.PopulateCol<string, INode>(src.NodeData, colIndex, stringVals);

            copier.CopyNodeData = true;
            copier.CopyEdgeData = false;
            var net = copier.CopyNetwork(src) as IBasicAdjList;

            Assert.NotNull(net);
            Assert.Equal(src.NodeCount, net.NodeCount);
            Assert.Equal(src.NodeCount, net.Nodes.Count);
            Assert.Equal(src.EdgeCount, net.EdgeCount);
            Assert.Equal(src.EdgeCount, net.Edges.Count);
            Assert.Equal(src.IsDirected, net.IsDirected);
            Assert.Equal(src.Name, net.Name);
            Assert.NotEqual(src.Id, net.Id);

            Assert.NotNull(net.NodeData);
            Assert.Equal(1, net.NodeData.ColumnCount);
            Assert.Equal(numNodes, net.NodeData.RowCount);

            object objVal = null;

            //-- strings
            var list0 = net.NodeData.GetColumnData<string>(0);
            string stringVal = null;
            for (int i = 0; i < list0.Count; i++)
            {
                objVal = list0[i];
                if(objVal!=null)
                {
                    Assert.IsType(typeof(string), objVal);
                    stringVal = (string)objVal;
                    Assert.Equal(stringVals[i], stringVal);
                }
            }
        }
        public void CopyNetwork_With_Node_Data_Attributes_When_Src_Has_None_Creates_Empty_Table(int testId, int numNodes, int numEdges, bool isDirected)
        {
            //Arrange
            var copier = new BasicAdjListCopier();
            IBasicAdjList src = BasicAdjListGenerator.GenerateAdjList(numNodes, numEdges, isDirected);

            Assert.Null(src.NodeData);
            Assert.Null(src.EdgeData);

            copier.CopyNodeData = true;
            copier.CopyEdgeData = false;
            var net = copier.CopyNetwork(src) as IBasicAdjList;

            Assert.NotNull(net);
            Assert.Equal(src.NodeCount, net.NodeCount);
            Assert.Equal(src.NodeCount, net.Nodes.Count);
            Assert.Equal(src.EdgeCount, net.EdgeCount);
            Assert.Equal(src.EdgeCount, net.Edges.Count);
            Assert.Equal(src.IsDirected, net.IsDirected);
            Assert.Equal(src.Name, net.Name);
            Assert.NotEqual(src.Id, net.Id);

            Assert.NotNull(net.NodeData);
            Assert.Null(net.EdgeData);
            Assert.Equal(0, net.NodeData.ColumnCount);
            Assert.Equal(numNodes, net.NodeData.RowCount);
        }
        public void CopyNetwork_With_Node_Data_Attributes_And_CopyNodeData_Is_False(int numNodes, int numEdges, bool isDirected, int[] intVals, double[] doubleVals, bool[] boolVals, string[] stringVals)
        {
            //Arrange
            var copier = new BasicAdjListCopier();
            IBasicAdjList src = BasicAdjListGenerator.GenerateAdjListWithDataAttribs(numNodes, numEdges, isDirected, true, false);
            var builder = new DataAttributesBuilder();
            var colIndex = builder.AddColumn((INodeAttributes)src, typeof(int));
            builder.PopulateCol<int, INode>(src.NodeData, colIndex, intVals);
            colIndex = builder.AddColumn((INodeAttributes)src, typeof(double));
            builder.PopulateCol<double, INode>(src.NodeData, colIndex, doubleVals);
            colIndex = builder.AddColumn((INodeAttributes)src, typeof(bool));
            builder.PopulateCol<bool, INode>(src.NodeData, colIndex, boolVals);
            colIndex = builder.AddColumn((INodeAttributes)src, typeof(string));
            builder.PopulateCol<string, INode>(src.NodeData, colIndex, stringVals);

            copier.CopyNodeData = false;
            var net = copier.CopyNetwork(src) as IBasicAdjList;

            Assert.Null(net.NodeData);
            Assert.Equal(0, net.NodeDataAttributeCount);
        }
        public void CopyNetwork_With_NewNetworId_And_Exclude_Data_Attributes(int nodeCount, int edgeCount, bool directed)
        {
            //Arrange
            var copier = new BasicAdjListCopier();
            IBasicAdjList src = BasicAdjListGenerator.GenerateAdjList(nodeCount, edgeCount, directed);
            Guid id = Guid.NewGuid();
            copier.NewNetworkId = id;
            IBasicAdjList net = copier.CopyNetwork(src) as IBasicAdjList;

            Assert.NotNull(net);
            Assert.Equal(net.NodeCount, src.NodeCount);
            Assert.Equal(net.Nodes.Count, src.NodeCount);
            Assert.Equal(net.EdgeCount, src.EdgeCount);
            Assert.Equal(net.Edges.Count, src.EdgeCount);
            Assert.Equal(net.IsDirected, src.IsDirected);
            Assert.Equal(net.Name, src.Name);
            Assert.Equal(id, net.Id);
            Assert.Equal(src.NodeAttributeCount, src.NodeAttributeCount);
            Assert.Equal(src.EdgeAttributeCount, src.EdgeAttributeCount);
        }