GetAvailableChangeScripts() public méthode

Gets the available change scripts.
public GetAvailableChangeScripts ( ) : ICollection
Résultat ICollection
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            var infoTextWriter = new LambdaTextWriter(WriteVerbose);

            List<ChangeScript> allChangeScripts = new DirectoryScanner(infoTextWriter, Encoding.UTF8, new DirectoryInfo(this.deltasDirectory))
                .GetChangeScripts();
            
            var repository = new ChangeScriptRepository(allChangeScripts);
            var changeScripts = repository.GetAvailableChangeScripts();

            DbmsFactory factory = new DbmsFactory(this.DatabaseType, this.ConnectionString);
            var queryExecuter = new QueryExecuter(factory);

            var schemaManager = new DatabaseSchemaVersionManager(queryExecuter, factory.CreateDbmsSyntax(), this.TableName);

            var appliedChanges = schemaManager.GetAppliedChanges();
            var notAppliedChangeScripts = changeScripts.Where(c => appliedChanges.All(a => a.ScriptNumber != c.ScriptNumber));

            var descriptionPrettyPrinter = new DescriptionPrettyPrinter();

            var objects = notAppliedChangeScripts
                .Select(script => new
                    {
                        Id = script.ScriptNumber,
                        Description = descriptionPrettyPrinter.Format(script.ScriptName),
                        File = script.FileInfo
                    });

            this.WriteObject(objects, true);
        }
        public void TestChangeScriptsMayBeNumberedFromZero()
        {
            ChangeScript zero = new ChangeScript(0);
            ChangeScript four = new ChangeScript(4);


            ChangeScript[] scripts = new ChangeScript[] {zero, four};
            ChangeScriptRepository repository =
                new ChangeScriptRepository(new List<ChangeScript>(scripts));

            List<ChangeScript> list = repository.GetAvailableChangeScripts().ToList();

            Assert.AreEqual(2, list.Count);
            Assert.AreSame(zero, list[0]);
            Assert.AreSame(four, list[1]);
        }
Exemple #3
0
        public void TestChangeScriptsMayBeNumberedFromZero()
        {
            ChangeScript zero = new ChangeScript("Scripts", 0);
            ChangeScript four = new ChangeScript("Scripts", 4);


            ChangeScript[]         scripts    = new ChangeScript[] { zero, four };
            ChangeScriptRepository repository =
                new ChangeScriptRepository(new List <ChangeScript>(scripts));

            List <ChangeScript> list = repository.GetAvailableChangeScripts().ToList();

            Assert.AreEqual(2, list.Count);
            Assert.AreSame(zero, list[0]);
            Assert.AreSame(four, list[1]);
        }
        public void TestGivenASetOfChangeScriptsReturnsThemCorrectly()
        {
            ChangeScript one = new ChangeScript(1);
            ChangeScript two = new ChangeScript(2);
            ChangeScript three = new ChangeScript(3);
            ChangeScript four = new ChangeScript(4);

            ChangeScript[] scripts = {three, two, four, one};

            ChangeScriptRepository repository = new ChangeScriptRepository(new List<ChangeScript>(scripts));

            List<ChangeScript> list = repository.GetAvailableChangeScripts().ToList();

            Assert.AreEqual(4, list.Count);
            Assert.AreSame(one, list[0]);
            Assert.AreSame(two, list[1]);
            Assert.AreSame(three, list[2]);
            Assert.AreSame(four, list[3]);
        }
Exemple #5
0
        public void TestGivenASetOfChangeScriptsReturnsThemCorrectly()
        {
            ChangeScript one   = new ChangeScript("Scripts", 1);
            ChangeScript two   = new ChangeScript("Scripts", 2);
            ChangeScript three = new ChangeScript("Scripts", 3);
            ChangeScript four  = new ChangeScript("Scripts", 4);

            ChangeScript[] scripts = { three, two, four, one };

            ChangeScriptRepository repository = new ChangeScriptRepository(new List <ChangeScript>(scripts));

            List <ChangeScript> list = repository.GetAvailableChangeScripts().ToList();

            Assert.AreEqual(4, list.Count);
            Assert.AreSame(one, list[0]);
            Assert.AreSame(two, list[1]);
            Assert.AreSame(three, list[2]);
            Assert.AreSame(four, list[3]);
        }