Example #1
0
        public void UpdateDatabaseTester()
        {
            //arrange
            string scriptsDirectory = Path.Combine("Scripts", GetType().Name.Replace("Tester", ""));
            var    settings         = new ConnectionSettings(".\\sqlexpress", "aliasqltest", true, null, null);

            new DbUpdater().UpdateDatabase(new ConnectionStringGenerator().GetConnectionString(settings, true), RequestedDatabaseAction.Drop, scriptsDirectory);

            //act
            bool success = new DbUpdater().UpdateDatabase(new ConnectionStringGenerator().GetConnectionString(settings, true), RequestedDatabaseAction.Create, scriptsDirectory).Success;


            //assert
            int records = 0;

            AssertUsdAppliedDatabaseScriptTable(settings, reader =>
            {
                while (reader.Read())
                {
                    records++;
                    reader["ScriptFile"].ShouldEqual("0001-Update.sql");
                }
            });

            success.ShouldEqual(true);
            records.ShouldEqual(1);
        }
Example #2
0
        public void DatabaseVersionTester()
        {
            //arrange
            string scriptsDirectory = Path.Combine("Scripts", GetType().Name.Replace("Tester", ""));
            var    settings         = new ConnectionSettings(".\\sqlexpress", "aliasqltest", true, null, null);

            new DbUpdater().UpdateDatabase(new ConnectionStringGenerator().GetConnectionString(settings, true), RequestedDatabaseAction.Drop, scriptsDirectory);
            int dbversionbeforeupdate = new DbUpdater().DatabaseVersion(new ConnectionStringGenerator().GetConnectionString(settings, true));

            bool updated = new DbUpdater().UpdateDatabase(new ConnectionStringGenerator().GetConnectionString(settings, true), RequestedDatabaseAction.Update, scriptsDirectory).Success;

            //act
            int dbversionafterupdate = new DbUpdater().DatabaseVersion(new ConnectionStringGenerator().GetConnectionString(settings, true));

            //assert
            dbversionbeforeupdate.ShouldEqual(0);
            dbversionafterupdate.ShouldEqual(1);
        }