Esempio n. 1
0
        /// <summary>Initializes a new instance of the <see cref="ActionFolderLogic"/> class.
        ///     Constructor</summary>
        /// <param name="mockActionFolderDAL">The mock Action Folder DAL.</param>
        private ActionFolderLogic(ActionFolderDAL mockActionFolderDAL)
        {
            this.actionFolderDAL = mockActionFolderDAL;
            this.ActionFolders = new BindingList<ActionFolder>(this.actionFolderDAL.GetAllActionFolders());

            // I have to create new fileSystemWatchers for all the action folders
            foreach (var actionFolder in this.ActionFolders)
            {
                if (!File.Exists(actionFolder.ScriptLocation) || !Directory.Exists(actionFolder.Folder))
                {
                    actionFolder.Active = false;
                    this.actionFolderDAL.UpdateActionFolder(actionFolder);
                }
                else
                {
                    // Create a new item
                    var tempFileSystemWatcher = new FileSystemWatcher { Path = actionFolder.Folder, Filter = actionFolder.FileType, EnableRaisingEvents = true };
                    tempFileSystemWatcher.Created += this.FileSystemWatcherCreated;
                    tempFileSystemWatcher.Renamed += this.FileSystemWatcherCreated;

                    actionFolder.FileSystemWatcher = tempFileSystemWatcher;
                }
            }
        }
 public static void ClassInitialize(TestContext textContext)
 {
     actionFolderDAL = new ActionFolderDAL();
 }