public void Can_Iterate_Through_File_Contents()
            {
                ScriptManager manager = new 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 _Setup()
            {
                _theFileSpec = "file1.sql";

                _mocks = new MockRepository();

                var fileService = _mocks.Stub<IFileSystemService>();
                SetupResult.For(fileService.GetSpecificFile(_theFileSpec)).Return(new FileInfo(_theFileSpec));

                _mocks.ReplayAll();

                _manager = new ScriptManager(fileService);
                _manager.AddSingle(_theFileSpec);
            }
            public void _Setup()
            {
                _mocks = new MockRepository();

                var fileService = _mocks.Stub<IFileSystemService>();
                SetupResult.For(fileService.GetSpecificFile(FIRSTFILE)).Return(new FileInfo(FIRSTFILE));
                SetupResult.For(fileService.GetSpecificFile(SECONDFILE)).Return(new FileInfo(SECONDFILE));
                SetupResult.For(fileService.GetSpecificFile(THIRDFILE)).Return(new FileInfo(THIRDFILE));

                _mocks.ReplayAll();

                _manager = new ScriptManager(fileService);

                _manager.AddSingle(FIRSTFILE);
                _manager.AddSingle(SECONDFILE);
                _manager.AddSingle(THIRDFILE);
            }
            public void All_Scripts_Are_Removed()
            {
                const string FIRSTFILE = "file1.sql";
                const string SECONDFILE = "file2.sql";

                var mocks = new MockRepository();

                var fileService = mocks.Stub<IFileSystemService>();
                SetupResult.For(fileService.GetSpecificFile(FIRSTFILE)).Return(new FileInfo(FIRSTFILE));
                SetupResult.For(fileService.GetSpecificFile(SECONDFILE)).Return(new FileInfo(SECONDFILE));

                mocks.ReplayAll();

                var manager = new ScriptManager(fileService);

                manager.AddSingle(FIRSTFILE);
                manager.AddSingle(SECONDFILE);

                Assert.IsNotEmpty(manager.Scripts);

                manager.ClearAll();

                Assert.IsEmpty(manager.Scripts);
            }
 public void Can_Bubble_Underlying_Exception_Up_To_Caller()
 {
     ScriptManager manager = new ScriptManager(new FileSystemService());
     Assert.Throws<DirectoryNotFoundException>(() => manager.AddWithWildcard("somefolderthatdoesntexist", "*.sql"));
 }
            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 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);
            }