public void CopyAttribute_Of_Ints_For_Nodes(int srcColIndex, int targColIndex, Type[] srcTypes, Type[] targTypes)
        {
            //Arrange
            var copier = new DataAttributeTableCopier();
            IBasicAdjList src = BasicAdjListGenerator.GenerateAdjListWithDataAttribs(3, 0, false, true, false);
            var builder = new DataAttributesBuilder();
            for (int i = 0; i < srcTypes.Length; i++)
            {
                var colIndex = builder.AddColumn((INodeAttributes)src, srcTypes[i]);
                builder.PopulateColRandomly(src.NodeData, colIndex);
            }

            IBasicAdjList targ = BasicAdjListGenerator.GenerateAdjListWithDataAttribs(3, 0, false, true, false);
            for (int i = 0; i < targTypes.Length; i++)
            {
                var colIndex = builder.AddColumn((INodeAttributes)targ, targTypes[i]);
            }
            var map = new Dictionary<INode, INode>();
            for(int i=0; i<src.NodeCount; i++)
            {
                map.Add(targ.Nodes[i], src.Nodes[i]);
            }

            var srcData = src.NodeData.GetColumnData<int>(srcColIndex);
            var targData = targ.NodeData.GetColumnData<int>(targColIndex);
            Assert.NotNull(srcData);
            Assert.NotNull(targData);
            Assert.Equal(srcData.Count, targData.Count);

            //Act
            copier.CopyAttribute(map, src.NodeData, targ.NodeData, srcColIndex, targColIndex);

            //Assert
            srcData = src.NodeData.GetColumnData<int>(srcColIndex);
            targData = targ.NodeData.GetColumnData<int>(targColIndex);
            for (int i = 0; i < srcData.Count; i++)
            {
                Assert.Equal(srcData[i], targData[i]);
            }
        }
        public void CopyAttributes_Throws_If_Target_Columns_Are_Invalid()
        {
            //Arrange
            var map = new Dictionary<INode, INode>();
            var copier = new DataAttributeTableCopier();
            var mockSrcNodeData = new Mock<IDataAttributes<INode>>();
            var mockTargNodeData = new Mock<IDataAttributes<INode>>();

            string[] nullStringArray = null;
            Type[] nullTypeArray = null;

            #region set expectations

            mockSrcNodeData.Setup(foo => foo.ColumnNames).Returns(nullStringArray);
            mockSrcNodeData.Setup(foo => foo.DataTypes).Returns(nullTypeArray);
            mockTargNodeData.Setup(foo => foo.ColumnNames).Returns(nullStringArray);
            mockTargNodeData.Setup(foo => foo.DataTypes).Returns(nullTypeArray);

            #endregion

            //Act, Assert
            var ex = Assert.Throws<ArgumentException>(() => copier.CopyAttributes(map, mockSrcNodeData.Object, mockTargNodeData.Object));
        }
        public void VerifySourceAndTargetColumns_Returns_True_When_Targ_Col_As_Src_Col_Match(int id, string[] srcColNames, Type [] srcColTypes, string[] targColNames, Type[] targColTypes)
        {
            //Arrange
            var copier = new DataAttributeTableCopier();

            //Act
            var result = copier.VerifySourceAndTargetColumns(srcColNames, srcColTypes, targColNames, targColTypes);

            //Assert
            Assert.True(result);
        }
        public void VerifySourceAndTargetColumns_Returns_False_When_Targ_Name_Not_Found_In_Src(int id, string[] srcColNames, Type[] srcColTypes, string[] targColNames, Type[] targColTypes)
        {
            //Arrange
            var copier = new DataAttributeTableCopier();

            //Act
            var result = copier.VerifySourceAndTargetColumns(srcColNames, srcColTypes, targColNames, targColTypes);

            //Assert
            Assert.False(result);
        }
        public void VerifySourceAndTargetColumns_Returns_False_If_Any_Param_Is_Null(int id, string[] srcColNames, Type[] srcColTypes, string[] targColNames, Type[] targColTypes)
        {
            //Arrange
            var copier = new DataAttributeTableCopier();

            //Act
            var result = copier.VerifySourceAndTargetColumns(srcColNames, srcColTypes, targColNames, targColTypes);

            //Assert
            Assert.False(result);
        }
        public void Copy_For_Nodes_Throws_If_targetAttribs_Is_Null()
        {
            //Arrange
            var copier = new DataAttributeTableCopier();
            var mockNodeData = new Mock<IDataAttributes<INode>>();

            //Act, Assert
            var ex = Assert.Throws<ArgumentNullException>(() => copier.Copy( mockNodeData.Object, null));
        }
        public void Copy_For_Nodes_Throws_If_Params_Are_Same()
        {
            //Arrange
            var copier = new DataAttributeTableCopier();
            var mockSrcNodeData = new Mock<IDataAttributes<INode>>();
            var mockTargNodeData = mockSrcNodeData;

            //Act, Assert
            var ex = Assert.Throws<ArgumentException>(() => copier.Copy(mockSrcNodeData.Object, mockTargNodeData.Object));
        }
        public void Copy_For_Nodes_For_Empty_Network(int numNodes, int numEdges, bool isDirected, bool selfLoops, bool multiEdges, int[] intVals, double[] doubleVals, bool[] boolVals, string[] stringVals)
        {
            //Arrange
            var copier = new DataAttributeTableCopier();

            #region Create src and target networks

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

            // create a copy of src network and enable node data attribs
            IBasicAdjList targ = new BasicAdjList(Guid.NewGuid(), isDirected);
            foreach (var srcNode in src.Nodes)
            {
                targ.CreateNode();
            }
            INode a;
            INode b;
            foreach (var srcEdge in src.Edges)
            {
                a = targ.Nodes[srcEdge.SourceNode.Index];
                b = targ.Nodes[srcEdge.DestinationNode.Index];
                targ.CreateEdge(a, b);
            }
            using (var fac = new DataAttributeTableFactory(targ))
            {
                fac.CreateNodeDataTable();
            }

            #endregion

            //Act
            copier.Copy(src.NodeData, targ.NodeData);

            //Assert
            Assert.NotNull(targ.NodeData);
            Assert.Equal(src.NodeData.ColumnCount, targ.NodeData.ColumnCount);
            Assert.Equal(numNodes, targ.NodeData.RowCount);

            for (int i = 0; i < targ.NodeDataAttributeCount; i++)
            {
                Assert.Equal(src.NodeData.DataTypes[i], targ.NodeData.DataTypes[i]);
                Assert.Equal(src.NodeData.ColumnNames[i], targ.NodeData.ColumnNames[i]);
                Assert.Equal(src.NodeData.ColumnDefaultValues[i], targ.NodeData.ColumnDefaultValues[i]);
            }
        }
        public void Copy_For_Edges_Throws_If_srcAttribs_Is_Null()
        {
            //Arrange
            var copier = new DataAttributeTableCopier();
            var mockEdgeData = new Mock<IDataAttributes<IEdge>>();

            //Act, Assert
            var ex = Assert.Throws<ArgumentNullException>(() => copier.Copy(null, mockEdgeData.Object));
        }
        public void CopyStructure_For_Nodes_With_0_Cols(int testId, int numNodes, int numEdges, bool isDirected, bool selfLoops, bool multiEdges)
        {
            //Arrange
            var copier = new DataAttributeTableCopier();

            #region Create src and target networks

            IBasicAdjList src = BasicAdjListGenerator.GenerateAdjListWithDataAttribs(numNodes, numEdges, isDirected, true, false);

            IBasicAdjList targ = BasicAdjListGenerator.GenerateAdjListWithDataAttribs(numNodes, numEdges, isDirected, true, false);

            #endregion

            //Act
            copier.CopyStructure(src.NodeData, targ.NodeData);

            //Assert
            Assert.NotNull(targ.NodeData);
            Assert.Equal(src.NodeData.ColumnCount, targ.NodeData.ColumnCount);
            Assert.Equal(numNodes, targ.NodeData.RowCount);

            for (int i = 0; i < targ.NodeDataAttributeCount; i++)
            {
                Assert.Equal(src.NodeData.DataTypes[i], targ.NodeData.DataTypes[i]);
                Assert.Equal(src.NodeData.ColumnNames[i], targ.NodeData.ColumnNames[i]);
                Assert.Equal(src.NodeData.ColumnDefaultValues[i], targ.NodeData.ColumnDefaultValues[i]);
            }
        }
        public void CopyStructure_For_Nodes(int testId, int numNodes, int numEdges, bool isDirected, bool selfLoops, bool multiEdges, int[] intVals, double[] doubleVals, bool[] boolVals, string[] stringVals)
        {
            //Arrange
            var copier = new DataAttributeTableCopier();

            #region Create src and target networks

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

            IBasicAdjList targ = BasicAdjListGenerator.GenerateAdjListWithDataAttribs(numNodes, numEdges, isDirected, true, false);
            //builder.AddColumn((INodeAttributes)src, typeof(int));
            //builder.AddColumn((INodeAttributes)src, typeof(double));
            //builder.AddColumn((INodeAttributes)src, typeof(bool));
            //builder.AddColumn((INodeAttributes)src, typeof(string));

            #endregion

            //Act
            copier.CopyStructure(src.NodeData, targ.NodeData);

            //Assert
            Assert.NotNull(targ.NodeData);
            Assert.Equal(src.NodeData.ColumnCount, targ.NodeData.ColumnCount);
            Assert.Equal(numNodes, targ.NodeData.RowCount);

            for (int i = 0; i < targ.NodeDataAttributeCount; i++ )
            {
                Assert.Equal(src.NodeData.DataTypes[i], targ.NodeData.DataTypes[i]);
                Assert.Equal(src.NodeData.ColumnNames[i], targ.NodeData.ColumnNames[i]);
                Assert.Equal(src.NodeData.ColumnDefaultValues[i], targ.NodeData.ColumnDefaultValues[i]);
            }
        }
        public void CopyAttribute_Throws_If_TargetColIndex_Is_Invalid(int targDataColCount, int targetColIndex)
        {
            //Arrange
            var map = new Dictionary<INode, INode>();
            var copier = new DataAttributeTableCopier();
            var mockSrcNodeData = new Mock<IDataAttributes<INode>>();
            var mockTargNodeData = new Mock<IDataAttributes<INode>>();

            #region set expectations

            mockSrcNodeData.Setup(foo => foo.ColumnCount).Returns(1);
            mockTargNodeData.Setup(foo => foo.ColumnCount).Returns(targDataColCount);

            #endregion

            //Act, Assert
            var ex = Assert.Throws<ArgumentException>(() => copier.CopyAttribute(map, mockSrcNodeData.Object, mockTargNodeData.Object, 0, targetColIndex));
        }
        public void CopyAttribute_Throws_If_DataTypes_Do_Not_Match()
        {
            //Arrange
            var map = new Dictionary<INode, INode>();
            var copier = new DataAttributeTableCopier();
            var mockSrcNodeData = new Mock<IDataAttributes<INode>>();
            var mockTargNodeData = new Mock<IDataAttributes<INode>>();

            #region set expectations

            mockSrcNodeData.Setup(foo => foo.ColumnCount).Returns(0);
            mockSrcNodeData.Setup(foo => foo.DataTypes).Returns(new Type[] { typeof(int) });
            mockTargNodeData.Setup(foo => foo.ColumnCount).Returns(0);
            mockTargNodeData.Setup(foo => foo.DataTypes).Returns(new Type[] { typeof(double) });

            #endregion

            //Act, Assert
            var ex = Assert.Throws<ArgumentException>(() => copier.CopyAttribute(map, mockSrcNodeData.Object, mockTargNodeData.Object, 0, 0));
        }