public void Can_Iterate_Through_File_Contents()
        {
            Core.ScriptManager manager = new Core.ScriptManager(new FileSystemService());

            manager.AddWithWildcard("TestScripts", "testscript*.sql");

            Assert.AreEqual(3, manager.ScriptContents.Count());

            Assert.AreEqual("sql script01", manager.ScriptContents.ElementAt(0));
            Assert.AreEqual("sql script02", manager.ScriptContents.ElementAt(1));
            Assert.AreEqual("sql script03", manager.ScriptContents.ElementAt(2));
        }
        public void Can_Iterate_Through_File_Contents()
        {
            Core.ScriptManager manager = new Core.ScriptManager(new FileSystemService());

            manager.AddWithWildcard("TestScripts", "testscript*.sql");

            Assert.AreEqual(3, manager.ScriptContents.Count());

            Assert.AreEqual("sql script01", manager.ScriptContents.ElementAt(0));
            Assert.AreEqual("sql script02", manager.ScriptContents.ElementAt(1));
            Assert.AreEqual("sql script03", manager.ScriptContents.ElementAt(2));
        }
        public void Can_Add_In_Order_Sorted_By_Name()
        {
            const string FIRSTFILE = "file1.sql";
            const string SECONDFILE = "file2.sql";
            const string THIRDFILE = "file3.sql";

            var mocks = new MockRepository();

            var fileService = mocks.Stub<IFileSystemService>();
            SetupResult.For(fileService.GetFilesInSpecificDirectory(".", "*.*")).Return(new[] { new FileInfo(SECONDFILE), new FileInfo(THIRDFILE), new FileInfo(FIRSTFILE) }.Select(x => new ScriptFile(x)).ToList());

            mocks.ReplayAll();

            var manager = new Core.ScriptManager(fileService);

            manager.AddWithWildcard(".", "*.*");

            Assert.AreEqual(FIRSTFILE, manager.Scripts.ElementAt(0).Name);
            Assert.AreEqual(SECONDFILE, manager.Scripts.ElementAt(1).Name);
            Assert.AreEqual(THIRDFILE, manager.Scripts.ElementAt(2).Name);
        }
Exemplo n.º 4
0
        public void Can_Add_In_Order_Sorted_By_Name()
        {
            const string FIRSTFILE  = "file1.sql";
            const string SECONDFILE = "file2.sql";
            const string THIRDFILE  = "file3.sql";

            var mocks = new MockRepository();

            var fileService = mocks.Stub <IFileSystemService>();

            SetupResult.For(fileService.GetFilesInSpecificDirectory(".", "*.*")).Return(new FileInfo[] { new FileInfo(SECONDFILE), new FileInfo(THIRDFILE), new FileInfo(FIRSTFILE) });

            mocks.ReplayAll();

            var manager = new Core.ScriptManager(fileService);

            manager.AddWithWildcard(".", "*.*");

            Assert.AreEqual(FIRSTFILE, manager.Scripts.ElementAt(0).Name);
            Assert.AreEqual(SECONDFILE, manager.Scripts.ElementAt(1).Name);
            Assert.AreEqual(THIRDFILE, manager.Scripts.ElementAt(2).Name);
        }
 public void Can_Bubble_Underlying_Exception_Up_To_Caller()
 {
     Core.ScriptManager manager = new Core.ScriptManager(new FileSystemService());
     Assert.Throws<DirectoryNotFoundException>(() => manager.AddWithWildcard("somefolderthatdoesntexist", "*.sql"));
 }
 public void Can_Bubble_Underlying_Exception_Up_To_Caller()
 {
     Core.ScriptManager manager = new Core.ScriptManager(new FileSystemService());
     Assert.Throws <DirectoryNotFoundException>(() => manager.AddWithWildcard("somefolderthatdoesntexist", "*.sql"));
 }