public void Merge(int rowCount0, int rowCount1, Type[] colTypes0, string[] colNames0, Type[] colTypes1, string[] colNames1)
        {
            SimpleFrame frame0 = SimpleFrameGenerator.CreateTable(rowCount0, colTypes0, colNames0);
            SimpleFrame frame1 = SimpleFrameGenerator.CreateTable(rowCount1, colTypes1, colNames1);

            SimpleFrameMerger merger = new SimpleFrameMerger();
            IFrame frameX = merger.Merge(frame0, frame1, Guid.NewGuid());

            Assert.IsNotNull(frameX, "SimpleFrame should not be null");

            int expectedColCount = frame0.ColumnCount + frame1.ColumnCount;

            Assert.AreEqual(expectedColCount, frameX.ColumnCount, "ColumnCount should match expected");
            Assert.AreEqual(frame0.RowCount, frameX.RowCount, "RowCount should match expected");
            Assert.AreEqual(frame1.RowCount, frameX.RowCount, "RowCount should match expected");

            // --------------
            SimpleFrame baseFrame = frameX as SimpleFrame;

            int colIndex = 0;
            int rowIndex = 0;
            for (int i = 0; i < colTypes0.Length; i++)
            {
                for (int j = 0; j < baseFrame.RowCount; j++)
                {
                    rowIndex = j;
                    colIndex = i;

                    bool result = baseFrame.Rows[rowIndex][colIndex].Equals(frame0.Rows[rowIndex][colIndex]);
                    Assert.IsTrue(result, "Items should match");

                    if (baseFrame.Columns[colIndex].DataType == typeof(int))
                    {
                        baseFrame.Rows[rowIndex][colIndex] = int.MinValue;
                    }
                    else if (baseFrame.Columns[colIndex].DataType == typeof(double))
                    {
                        baseFrame.Rows[rowIndex][colIndex] = double.MinValue;
                    }
                    else if (baseFrame.Columns[colIndex].DataType == typeof(string))
                    {
                        baseFrame.Rows[rowIndex][colIndex] = (rowIndex + colIndex).ToString();
                    }
                    else if (baseFrame.Columns[colIndex].DataType == typeof(DateTime))
                    {
                        baseFrame.Rows[rowIndex][colIndex] = DateTime.Now;
                    }
                    else if (baseFrame.Columns[colIndex].DataType == typeof(bool))
                    {
                        baseFrame.Rows[rowIndex][colIndex] = !((bool)frame0.Rows[rowIndex][colIndex]);
                    }
                    else if (baseFrame.Columns[colIndex].DataType == typeof(Guid))
                    {
                        baseFrame.Rows[rowIndex][colIndex] = Guid.NewGuid();
                    }

                    result = baseFrame.Rows[rowIndex][colIndex] == frame0.Rows[rowIndex][colIndex];
                    Assert.IsFalse(result, "A: Items should NOT match after change");
                }
            }

            int offset = colTypes0.Length;
            int k = 0;
            for (int i = 0; i < colTypes1.Length; i++)
            {
                k = (i + offset);

                for (int j = 0; j < baseFrame.RowCount; j++)
                {
                    rowIndex = j;
                    colIndex = k;

                    bool result = baseFrame.Rows[rowIndex][colIndex].Equals(frame1.Rows[rowIndex][i]);
                    Assert.IsTrue(result, "Items should match");

                    if (baseFrame.Columns[colIndex].DataType == typeof(int))
                    {
                        baseFrame.Rows[rowIndex][colIndex] = int.MinValue;
                    }
                    else if (baseFrame.Columns[colIndex].DataType == typeof(double))
                    {
                        baseFrame.Rows[rowIndex][colIndex] = double.MinValue;
                    }
                    else if (baseFrame.Columns[colIndex].DataType == typeof(string))
                    {
                        baseFrame.Rows[rowIndex][colIndex] = (rowIndex + colIndex).ToString();
                    }
                    else if (baseFrame.Columns[colIndex].DataType == typeof(DateTime))
                    {
                        baseFrame.Rows[rowIndex][colIndex] = DateTime.Now;
                    }
                    else if (baseFrame.Columns[colIndex].DataType == typeof(bool))
                    {
                        baseFrame.Rows[rowIndex][colIndex] = !((bool)frame1.Rows[rowIndex][i]);
                    }
                    else if (baseFrame.Columns[colIndex].DataType == typeof(Guid))
                    {
                        baseFrame.Rows[rowIndex][colIndex] = Guid.NewGuid();
                    }

                    result = baseFrame.Rows[rowIndex][colIndex] == frame1.Rows[rowIndex][i];
                    Assert.IsFalse(result, "B: Items should NOT match after change");
                }
            }
        }
        public void Merge_VerifyIdInNewFrame()
        {
            SimpleFrame frame0 = SimpleFrameGenerator.CreateTable(2, new Type[] { typeof(int) });
            SimpleFrame frame1 = SimpleFrameGenerator.CreateTable(2, new Type[] { typeof(double) });

            Guid id = Guid.NewGuid();
            SimpleFrameMerger merger = new SimpleFrameMerger();
            IFrame frameX = merger.Merge(frame0, frame1, id);

            Assert.IsNotNull(frameX, "SimpleFrame should not be null");
            Assert.AreEqual(id, frameX.Id, "Id should match expected");
        }
        public void Merge_VerifyAllColNamesAreUnique(int rowCount0, int rowCount1, Type[] colTypes0, string[] colNames0, Type[] colTypes1, string[] colNames1)
        {
            SimpleFrame frame0 = SimpleFrameGenerator.CreateTable(rowCount0, colTypes0, colNames0) as SimpleFrame;
            SimpleFrame frame1 = SimpleFrameGenerator.CreateTable(rowCount1, colTypes1, colNames1) as SimpleFrame;

            SimpleFrameMerger merger = new SimpleFrameMerger();
            IFrame frameX = merger.Merge(frame0, frame1, Guid.NewGuid());

            Assert.IsNotNull(frameX, "SimpleFrame should not be null");

            int expectedColCount = frame0.ColumnCount + frame1.ColumnCount;

            Assert.AreEqual(expectedColCount, frameX.ColumnCount, "ColumnCount should match expected");
            Assert.AreEqual(frame0.RowCount, frameX.RowCount, "RowCount should match expected");
            Assert.AreEqual(frame1.RowCount, frameX.RowCount, "RowCount should match expected");

            //-----------------------------------------------------
            // Verify all col names are unique
            for (int i = 0; i < frameX.ColumnNames.Length; i++)
            {
                for (int j = 0; j < frameX.ColumnNames.Length; j++)
                {
                    if (i == j)
                        continue;
                    Assert.AreNotEqual(frameX.ColumnNames[i], frameX.ColumnNames[j], "No column name should match any of the others.");
                }
            }
        }
        public void Merge_VerifiesSupportedImplementations(DataObjectImplementation imp0, DataObjectImplementation imp1)
        {
            IFrame mockFrame0 = RecorderManager.CreateMockedObject(typeof(BlueSpider.Blob.Common.Data.IFrame)) as IFrame;
            IFrame mockFrame1 = RecorderManager.CreateMockedObject(typeof(BlueSpider.Blob.Common.Data.IFrame)) as IFrame;

            using (RecordExpectations recorder = RecorderManager.StartRecording())
            {
                recorder.DefaultBehavior.Strict = StrictFlags.AllMethods;
                recorder.ExpectAndReturn(mockFrame0.RowCount, 1).RepeatAlways();
                recorder.ExpectAndReturn(mockFrame1.RowCount, 1).RepeatAlways();
                recorder.ExpectAndReturn(mockFrame0.Implementation, imp0).RepeatAlways();
                recorder.ExpectAndReturn(mockFrame1.Implementation, imp1).RepeatAlways();
            }

            SimpleFrameMerger merger = new SimpleFrameMerger();
            IFrame frameX = merger.Merge(mockFrame0, mockFrame1, Guid.NewGuid());
            MockManager.Verify();
        }
        public void Merge_ThrowsExIfRowCountsDoNotMatch(int rowCount0, int rowCount1, Type[] colTypes0, Type[] colTypes1)
        {
            SimpleFrame frame0 = SimpleFrameGenerator.CreateTable(rowCount0, colTypes0) as SimpleFrame;
            SimpleFrame frame1 = SimpleFrameGenerator.CreateTable(rowCount1, colTypes1) as SimpleFrame;

            SimpleFrameMerger merger = new SimpleFrameMerger();
            IFrame frameX = merger.Merge(frame0, frame1, Guid.NewGuid());
        }
        public void Merge_ThrowsExIfBothInputFramesAreTheSame()
        {
            IFrame frame0 = SimpleFrameGenerator.CreateTable(1, new Type[] { typeof(string) });
            IFrame frame1 = frame0;

            SimpleFrameMerger merger = new SimpleFrameMerger();
            IFrame frameX = merger.Merge(frame0, frame1, Guid.NewGuid());
        }