protected override void ProcessRecord()
        {
            base.ProcessRecord();

            var infoTextWriter = new LambdaTextWriter(WriteVerbose);

            List<ChangeScript> allChangeScripts =
                new DirectoryScanner(infoTextWriter).GetChangeScriptsForDirectory(new DirectoryInfo(_deltasDirectory));
            
            var repository = new ChangeScriptRepository(allChangeScripts);
            var changeScripts = repository.GetOrderedListOfDoChangeScripts();

            var appliedChangeNumbers = _databaseSchemaVersion.GetAppliedChangeNumbers();
            var notAppliedChangeScripts = changeScripts.Where(c => !appliedChangeNumbers.Contains(c.GetId()));

            var descriptionPrettyPrinter = new DescriptionPrettyPrinter();

            var objects =
                notAppliedChangeScripts
                    .Select(script => new
                                          {
                                              Id = script.GetId(),
                                              Description = descriptionPrettyPrinter.Format(script.GetDescription()),
                                              File = script.GetFile()
                                          });

            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.GetOrderedListOfDoChangeScripts();

            Assert.AreEqual(2, list.Count);
            Assert.AreSame(zero, list[0]);
            Assert.AreSame(four, list[1]);
        }
        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.GetOrderedListOfDoChangeScripts();

            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.GetOrderedListOfDoChangeScripts();

            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]);
        }
        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.GetOrderedListOfDoChangeScripts();

            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]);
        }