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 void Displaytable_should_return_table_partial_view()
        {
            const string tableName = "tableName";

            var table = new Table(tableName);

            _schemaReader.Expect(sr => sr.GetTable(Arg<string>.Is.Anything, Arg<string>.Is.Anything)).Return(table);

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

            var result = _databaseExplorerController.DisplayTable(tableName);

            Assert.IsNotNull(result);
            Assert.AreEqual("Table", result.ViewName);
            Assert.IsInstanceOf<Table>(result.ViewData.Model);
            Assert.AreEqual(table.Name, ((Table)result.ViewData.Model).Name);
        }
        public void Should_use_connectionstringargumentsmapperfactory_to_make_aconnectionstringargumentmapper()
        {
            const string databaseType = "Access";

            _databaseExplorerController = new DatabaseExplorerController(_schemaReader, _connectionstringBuilder, _connectionstringArgumentsMapperFactory);

            _databaseExplorerController.GetTablesList(new DatabaseConnection{ DatabaseType = databaseType});

            _connectionstringArgumentsMapperFactory.AssertWasCalled(factory => factory.Make(databaseType));
        }