コード例 #1
0
        public void MethodCallsFromADictionaryConstructedObject()
        {
            WlbScheduledTasks tasks = new WlbScheduledTasks(new Dictionary<string, string>()
                                                                {
                                                                   {"schedTask_dosomething", "now"},
                                                                   {"schedTask_3", "later"},
                                                                   {"schedTask_1", "sooner"},
                                                                   {"domoresomethings", "will not be added"} 
                                                                });
            //Task List Construction
            Assert.AreEqual(3, tasks.TaskList.Count );
            Assert.AreEqual(0, tasks.TaskList["dosomething"].TaskId);
            Assert.AreEqual(1, tasks.TaskList["1"].TaskId);
            Assert.AreEqual(3, tasks.TaskList["3"].TaskId);

            //Dictionary Conversion
            Assert.AreEqual(3, tasks.ToDictionary().Count, "Conversion to dictionary");

            //Sorted Tasks
            SortedDictionary<int, WlbScheduledTask> sortedTasks = tasks.SortedTaskList;
            Assert.AreEqual(3, sortedTasks.Count, "SortedTaskList");
            List<WlbScheduledTask> tasksValues = new List<WlbScheduledTask>(sortedTasks.Values);
            Assert.AreEqual(0, tasksValues[0].TaskId);
            Assert.AreEqual(3, tasksValues[1].TaskId);
            Assert.AreEqual(1, tasksValues[2].TaskId);

            //Virtual Tasks
            Assert.AreEqual(0, tasks.VirtualTaskList.Count, "VirtualTaskList");
            
            //Next task
            WlbScheduledTask nextTask = tasks.GetNextExecutingTask();
            Assert.IsNull( nextTask, "GetNextExecutingTask");
        }
コード例 #2
0
 public void MethodCallsFromAnEmptyConstructor()
 {
     WlbScheduledTasks tasks = new WlbScheduledTasks();
     Assert.AreEqual(0, tasks.TaskList.Count, "TaskList");
     Assert.AreEqual(0, tasks.SortedTaskList.Count, "SortedTaskList");
     Assert.AreEqual(0, tasks.VirtualTaskList.Count, "VirtualTaskList");
     Assert.IsNull(tasks.ToDictionary(), "Conversion to dictionary");
     Assert.IsNull(tasks.GetNextExecutingTask(), "GetNextExecutingTask");
 }
コード例 #3
0
 public WlbPoolConfiguration(Dictionary <string, string> configuration)
 {
     if (null != configuration)
     {
         base.Configuration = configuration;
         PopulateKeyValues();
         _hostConfigurations = new WlbHostConfigurations(base.Configuration);
         _scheduledTasks     = new WlbScheduledTasks(base.Configuration);
     }
     else
     {
         throw new Exception("WLBPoolConfiguration is null");
     }
 }
コード例 #4
0
 public WlbPoolConfiguration(Dictionary<string, string> configuration)
 {
     if (null != configuration)
     {
         base.Configuration = configuration;
         PopulateKeyValues();
         _hostConfigurations = new WlbHostConfigurations(base.Configuration);
         _scheduledTasks = new WlbScheduledTasks(base.Configuration);
     }
     else
     {
         throw new Exception("WLBPoolConfiguration is null");
     }
 }
コード例 #5
0
 public void EmptyConstructorCausesLastTaskToThrow()
 {
     WlbScheduledTasks tasks = new WlbScheduledTasks();
     tasks.GetLastExecutingTask();
 }
コード例 #6
0
 public void EmptyConstructorCausesCurrentScheduledPerformanceModeToThrow()
 {
     WlbScheduledTasks tasks = new WlbScheduledTasks();
     tasks.GetCurrentScheduledPerformanceMode();
 }
コード例 #7
0
        private WlbScheduledTasks BuildSampleTasksWithTimes()
        {
            WlbScheduledTasks tasks = new WlbScheduledTasks();

            Dictionary<string, string > taskParameters = new Dictionary<string, string>()
                                                             {
                                                                 { "OptMode", "1"} // Performance mode
                                                             };

            WlbScheduledTask taskA = new WlbScheduledTask("1")
                                         { 
                                             DaysOfWeek = WlbScheduledTask.WlbTaskDaysOfWeek.Friday,
                                             TaskParameters = taskParameters
                                         };
            WlbScheduledTask taskB = new WlbScheduledTask("2")
                                         {
                                             DaysOfWeek = WlbScheduledTask.WlbTaskDaysOfWeek.Monday,
                                             TaskParameters = taskParameters
                                         };

            //Weekend tasks adds 2 to the virtual task list, one for each day
            WlbScheduledTask taskC = new WlbScheduledTask("3")
                                         {
                                             DaysOfWeek = WlbScheduledTask.WlbTaskDaysOfWeek.Weekends,
                                             TaskParameters = taskParameters
                                         };
            Dictionary<string, WlbScheduledTask> taskCollection = new Dictionary<string, WlbScheduledTask>()
                                                                      {
                                                                          {"schedTask_1", taskA},
                                                                          {"schedTask_2", taskB},
                                                                          {"schedTask_3", taskC}
                                                                      };

            Assert.AreEqual(3, taskCollection.Count, "Setting up task collection");
            tasks.TaskList = taskCollection;
            return tasks;
        }