public void CreateTableIfNotExistent_WhenSimplestType()
        {
            var helper = new SqliteDatabaseCreationHelper();

            helper.CreateTableIfNotExistentAsync <MySimpleClass>(TableName, Fixture.Connection).Wait();
            CheckTableCreationStatement <MySimpleClass>(new[] { "Id integer" });
        }
        public void CreateTableIfNotExistent_WhenTypeHasPrimaryKey()
        {
            var helper = new SqliteDatabaseCreationHelper();

            helper.CreateTableIfNotExistentAsync <MyClassWithPrimaryKey>(TableName, Fixture.Connection).Wait();
            CheckTableCreationStatement <MyClassWithPrimaryKey>(new[] { "Id integer not null primary key asc" });
        }
        public void CreateTableIfNotExistent_WhenTypeHasIndexWithContraint()
        {
            var helper = new SqliteDatabaseCreationHelper();

            helper.CreateTableIfNotExistentAsync <MyClassWithContrainedIndex>(TableName, Fixture.Connection).Wait();
            CheckIndexCreationStatement <MyClassWithContrainedIndex>("Id");
        }
        public void CreateTableIfNotExistent_WhenTableAlreadyExists()
        {
            Fixture.Connection.Execute($"create table {TableName} (dummy_column integer)");
            var helper = new SqliteDatabaseCreationHelper();

            helper.CreateTableIfNotExistentAsync <MySimpleClass>(TableName, Fixture.Connection).Wait();
            Assert.NotNull(Fixture.ReadActualTableSchemaFromDatabase(TableName));
        }
        public void CreateTableIfNotExistent_WhenPrimaryKeyAlsoIndex_ThenThrow()
        {
            var helper = new SqliteDatabaseCreationHelper();

            Assert.ThrowsAsync <Common.OrmException>(() =>
                                                     helper.CreateTableIfNotExistentAsync <MyClassWithConflictingAttributes>(
                                                         TableName, Fixture.Connection)
                                                     );
        }
        public void CreateTableIfNotExistent_WhenManyPrimaryKeys_ThenThrow()
        {
            var helper = new SqliteDatabaseCreationHelper();

            Assert.ThrowsAsync <Common.OrmException>(() =>
                                                     helper.CreateTableIfNotExistentAsync <MyClassWithTwoPrimaryKeys>(
                                                         TableName, Fixture.Connection)
                                                     );
        }
        public void CreateTableIfNotExistent_WhenManyTypes_ThenTableHasCorrespondingSqlTypes()
        {
            var helper = new SqliteDatabaseCreationHelper();

            helper.CreateTableIfNotExistentAsync <Person>(TableName, Fixture.Connection).Wait();

            CheckTableCreationStatement <Person>(new[] {
                "Id integer",
                "Name text",
                "Gender text",
                "BirthDate text",
                "IsAlive integer",
                "Height real",
                "UniversalId text",
                "Picture blob"
            });
        }