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); }
private Table GetTableInfo(string connectionstring, string tableName, IEnumerable<ForeignKey> foreignKeys) { var columns = Task<ICollection<Column>>.Factory.StartNew(() => GetColumns(connectionstring, tableName)); var indexes = Task<IList<Index>>.Factory.StartNew(() => GetIndexes(connectionstring, tableName)); var table = new Table(tableName) { Columns = columns.Result, Indexes = indexes.Result, ForeignKeys = GetForeignKeysForTable(tableName, foreignKeys) }; if(!table.Columns.Any()) { throw new TableNotFoundException(string.Format("Table '{0}' not found.", tableName)); } return table; }