Beispiel #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);
        }
Beispiel #2
0
        public void PendingChangesTester()
        {

            //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);
            bool updated = new DbUpdater().UpdateDatabase(new ConnectionStringGenerator().GetConnectionString(settings, true), RequestedDatabaseAction.Update, scriptsDirectory).Success;

            //act
            List<string> pendingChanges = new DbUpdater().PendingChanges(new ConnectionStringGenerator().GetConnectionString(settings, true), scriptsDirectory.Replace("DbUpdater", "NewEverytimeScript"));

            //assert
            pendingChanges.Count.ShouldEqual(1);
        }
Beispiel #3
0
        public void DatabaseExistsTester()
        {

            //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 dbexistsbefore = new DbUpdater().DatabaseExists(new ConnectionStringGenerator().GetConnectionString(settings, true));

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

            bool dbexistsafter = new DbUpdater().DatabaseExists(new ConnectionStringGenerator().GetConnectionString(settings, true));
           
            //assert
            dbexistsbefore.ShouldEqual(false);
            dbexistsafter.ShouldEqual(true);
        }