public void Getforeignkeyconnections_should_return_table_tablesconnections_as_jason()
        {
            var foreignKeyColumn = new ForeignKeyColumn {Name = "foreignKeyColumn"};
            var primaryKeyColumn = new PrimaryKeyColumn { Name = "primaryKeyColumn" };

            var foreignKeys = new List<ForeignKey>
            {
                new ForeignKey
                {
                    ForeignKeyTableName = "ForeignKeyTableName",
                    PrimaryKeyTableName = "PrimaryKeyTableName",
                    ForeignKeyColumns = new List<ForeignKeyColumn> { foreignKeyColumn },
                    PrimaryKeysColumns = new List<PrimaryKeyColumn>{ primaryKeyColumn}
                }
            };

            _schemaReader.Expect(sr => sr.GetForeignKeys(Connectionstring)).Return(foreignKeys);

            _connectionstringArgumentsMapperFactory = new ConnectionstringArgumentsMapperFactory();

            _databaseExplorerController = new DatabaseExplorerController(_schemaReader, _connectionstringBuilder, _connectionstringArgumentsMapperFactory);
            _databaseExplorerController.ControllerContext = new ControllerContext(_context, new RouteData(), _databaseExplorerController);

            var result = _databaseExplorerController.GetForeignKeyConnections() as JsonResult;

            Assert.IsNotNull(result);

            var serializer = new JavaScriptSerializer();
            var output = serializer.Serialize(result.Data);
            Console.WriteLine(output);

            Assert.AreEqual("[{\"Name\":null,\"OriginalName\":null,\"ForeignKeyTableName\":\"ForeignKeyTableName\",\"ForeignKeyTableSchema\":null,\"ForeignKeyColumns\":[{\"Name\":\"foreignKeyColumn\"}],\"PrimaryKeyTableName\":\"PrimaryKeyTableName\",\"PrimaryKeyTableSchema\":null,\"PrimaryKeysColumns\":[{\"Name\":\"primaryKeyColumn\"}]}]", output);
        }
        public ForeignKey MapToForeignKey(DataRow row, DataTable schema)
        {
            var dbForeignKey = new ForeignKey
            {
                Name                  = row["FK_NAME"].ToString(),
                OriginalName          = row["FK_NAME"].ToString(),
                ForeignKeyTableName   = row["FK_TABLE_NAME"].ToString(),
                PrimaryKeyTableName   = row["PK_TABLE_NAME"].ToString(),
                ForeignKeyTableSchema = schema.ToString()
            };

            var fkc = new ForeignKeyColumn { Name = row["FK_COLUMN_NAME"].ToString() };
            dbForeignKey.ForeignKeyColumns.Add(fkc);

            var pkc = new PrimaryKeyColumn { Name = row["PK_COLUMN_NAME"].ToString() };
            dbForeignKey.PrimaryKeysColumns.Add(pkc);

            return dbForeignKey;
        }