public void When_getting_table_info_of_a_non_existing_table() { using (var conn = new SQLiteInMemoryConnection()) { var ex1 = Should.Throw <InvalidOperationException>(() => conn.GetTableInfo <Person>()); ex1.Message.ShouldBe("Table: [Person] does not exist."); var ex2 = Should.Throw <InvalidOperationException>(() => conn.GetTableInfo("Bambolini")); ex2.Message.ShouldBe("Table: Bambolini does not exist."); } }
public async Task When_getting_table_info_of_aliased_model() { using (var conn = new SQLiteInMemoryConnection()) { await conn.ExecuteAsync(TableQuery); var tableInfo = await conn.GetTableInfo <MyPerson>(); tableInfo.ShouldNotBeNull(); tableInfo.TableName.ShouldBe("Person"); tableInfo.SQL.ShouldBe(TableQuery.Replace("IF NOT EXISTS ", string.Empty).Replace(";", string.Empty)); tableInfo.Columns.Length.ShouldBe(3); Array.TrueForAll(tableInfo.Columns, i => i.TableName == "Person").ShouldBeTrue(); tableInfo.Columns[0].Id.ShouldBe(0); tableInfo.Columns[0].Name.ShouldBe("Id"); tableInfo.Columns[0].Type.ShouldBe(SQLiteDataType.INTEGER); tableInfo.Columns[0].DefaultValue.ShouldBeNull(); tableInfo.Columns[0].IsPrimaryKey.ShouldBeTrue(); tableInfo.Columns[0].NotNull.ShouldBeTrue(); tableInfo.Columns[1].Id.ShouldBe(1); tableInfo.Columns[1].Name.ShouldBe("Name"); tableInfo.Columns[1].Type.ShouldBe(SQLiteDataType.TEXT); tableInfo.Columns[1].DefaultValue.ShouldBeNull(); tableInfo.Columns[1].IsPrimaryKey.ShouldBeFalse(); tableInfo.Columns[1].NotNull.ShouldBeTrue(); tableInfo.Columns[2].Id.ShouldBe(2); tableInfo.Columns[2].Name.ShouldBe("Age"); tableInfo.Columns[2].Type.ShouldBe(SQLiteDataType.INTEGER); tableInfo.Columns[2].DefaultValue.ShouldBeNull(); tableInfo.Columns[2].IsPrimaryKey.ShouldBeFalse(); tableInfo.Columns[2].NotNull.ShouldBeTrue(); } }