Beispiel #1
0
        public void ToggleComplete_Off_InCollection()
        {
            // Not complete - doesn't include completed date
            var task = new Task("X (B) ToggleComplete_Off_InCollection +test @task");
            var tl   = new TaskList(_testDataPath);

            tl.Add(task);

            task = tl.Last();

            task.ToggleCompleted();

            task = tl.Last();

            Assert.IsTrue(task.Completed);

            var task2 = new Task("X 2011-02-25 ToggleComplete_Off_InCollection +test @task");

            tl.Add(task2);

            task = tl.Last();

            task.ToggleCompleted();

            task = tl.Last();

            Assert.IsFalse(task.Completed);
        }
Beispiel #2
0
        /// <summary>
        /// 在指定时间点插入新任务
        /// <code>Insert(0.5f, t); //任务t在序列开始后的0.5秒后被执行</code>
        /// </summary>
        public void Insert(float atTime, Task task)
        {
            TaskList list = new TaskList();

            list.Add(Delay(atTime, useUnscaledTime));
            list.Add(task);

            Add(list);
        }
Beispiel #3
0
        public void AddWithoutTagTest()
        {
            var list  = new TaskList();
            var task1 = list.Add(TwoFramesTask());
            var task2 = list.Add(TwoFramesTask);

            Assert.That(list.Contains(task1));
            Assert.That(task1.Tag, Is.Null);
            Assert.That(list.Contains(task2));
            Assert.That(task2.Tag, Is.Null);
            Assert.That(task1, Is.Before(task2).In(list));
        }
		public void Add_Multiple()
		{
			var tl = new TaskList(_testDataPath);
			int c = tl.Count();

			var task = new Task("Add_Multiple task one");
			tl.Add(task);

			var task2 = new Task("Add_Multiple task two");
			tl.Add(task2);

			Assert.AreEqual(c + 2, tl.Count());
		}
Beispiel #5
0
        public void StopTest()
        {
            var list  = new TaskList();
            var task1 = list.Add(TwoFramesTask);
            var task2 = list.Add(TwoFramesTask);
            var task3 = list.Add(TwoFramesTask);

            list.Stop();
            Assert.That(list, Is.Empty);
            Assert.That(task1.Completed);
            Assert.That(task2.Completed);
            Assert.That(task3.Completed);
        }
Beispiel #6
0
        public void AddWithTagTest()
        {
            var list  = new TaskList();
            var tag1  = new object();
            var tag2  = new object();
            var task1 = list.Add(TwoFramesTask(), tag1);
            var task2 = list.Add(TwoFramesTask, tag2);

            Assert.That(list.Contains(task1));
            Assert.That(task1.Tag, Is.EqualTo(tag1));
            Assert.That(list.Contains(task2));
            Assert.That(task2.Tag, Is.EqualTo(tag2));
            Assert.That(task1, Is.Before(task2).In(list));
        }
Beispiel #7
0
        public void Add_Multiple()
        {
            var tl = new TaskList(_testDataPath);
            int c  = tl.Count();

            var task = new Task("Add_Multiple task one");

            tl.Add(task);

            var task2 = new Task("Add_Multiple task two");

            tl.Add(task2);

            Assert.AreEqual(c + 2, tl.Count());
        }
Beispiel #8
0
 public Task <TestResultContainer> Abort(Exception exception)
 {
     RemoveAllCheckTasks_();
     openTask_?.SetException(exception);
     if (closeTask_ != null)
     {
         if (closeTask_.TaskType == TaskType.Close)
         {
             closeTask_.SetExceptionAndAbort(exception);
         }
     }
     else
     {
         VisualGridTask abortTask = new VisualGridTask(null, null, eyes_, TaskType.Abort, taskListener_, null, null, this, null);
         lock (TaskList)
         {
             TaskList.Add(abortTask);
         }
         closeTask_ = abortTask;
         Task <TestResultContainer> futureTask = new Task <TestResultContainer>(abortTask.Call, abortTask);
         taskToFutureMapping_[abortTask] = futureTask;
         isCloseTaskIssued_ = true;
     }
     return(taskToFutureMapping_[closeTask_]);
 }
Beispiel #9
0
 public static void Add(this TaskList taskList, params ITaskProvider[] collection)
 {
     foreach (var i in collection)
     {
         taskList.Add(i.Task());
     }
 }
Beispiel #10
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public MainWindowVM()
        {
            var tasks = SubTaskMgr.Instance.TaskList;

            foreach (var task in tasks)
            {
                m_dict.Add(task.ID, new TaskWrapper(task));
            }

            // 构建关系树
            foreach (var wrapper in m_dict.Values)
            {
                foreach (var depend in wrapper.Depends)
                {
                    var parent = m_dict[depend];
                    parent.Children.Add(wrapper);
                    wrapper.Parents.Add(parent);
                }

                TaskList.Add(wrapper);
            }

            // 计算序号
            CalculateColumn();

            // 添加链接线段
            foreach (var task in m_dict.Values)
            {
                foreach (var line in task.GetLinks())
                {
                    TaskList.Add(line);
                }
            }
        }
Beispiel #11
0
        private void frmAddPlanTask_Load(object sender, EventArgs e)
        {
            string           errMsg            = string.Empty;
            TaskCategroyList _taskCategroyList = XmlHelper.LoadFromXml <TaskCategroyList>(Program.GetConfigPath("category.xml"), ref errMsg);

            if (!string.IsNullOrEmpty(errMsg))
            {
                WinFormLib.Core.MessageBoxHelper.ShowError(errMsg);
                return;
            }
            comCategorys.Items.Clear();
            foreach (var item in _taskCategroyList)
            {
                comCategorys.Items.Add(item.CategroyName.Value);
                foreach (var category in item.TaskItemList)
                {
                    string   taskFilePath = @"categroy\" + category.CategroyName.Value + @"\" + category.TaskName.Value + ".xml";
                    TaskItem entity       = XmlHelper.LoadFromXml <TaskItem>(Program.GetConfigPath(taskFilePath), ref errMsg);
                    if (!string.IsNullOrEmpty(errMsg))
                    {
                        WinFormLib.Core.MessageBoxHelper.ShowError(errMsg);
                        return;
                    }
                    taskList.Add(entity);
                }
            }
            if (comCategorys.Items.Count > 0)
            {
                comCategorys.SelectedIndex = 0;
            }
        }
Beispiel #12
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            if (InPreSolve)
            {
                ///First pass; collect data and construct tasks
                ///
                string cubeLoc = "";
                string equiLoc = "";
                ///allow for no input for width
                int w = 0;
                DA.GetData <int>(2, ref w);

                Task <SolveResults> tsk = null;

                if (DA.GetData <string>(0, ref cubeLoc) && DA.GetData <string>(1, ref equiLoc))
                {
                    tsk = Task.Run(() => Compute(cubeLoc, equiLoc, w), CancelToken);
                }

                ///Add a null task even if data collection fails.  This keeps the list size in sync with the iterations
                TaskList.Add(tsk);
                return;
            }


            if (!GetSolveResults(DA, out var results))
            {
                ///Compute right here, right now.
                ///1. Collect
                ///
                string cubeLoc = "";
                string equiLoc = "";
                int    w       = 0;

                if (!DA.GetData <string>(0, ref cubeLoc))
                {
                    return;
                }
                if (!DA.GetData <string>(1, ref equiLoc))
                {
                    return;
                }
                if (!DA.GetData <int>(1, ref w))
                {
                    return;
                }

                ///2. Compute
                ///
                results = Compute(cubeLoc, equiLoc, w);
            }

            ///3. Set
            ///
            if (results != null)
            {
                DA.SetData(0, results.Converted);
                DA.SetData(1, results.EquiFileLoc);
            }
        }
Beispiel #13
0
        public void StopByTagTest()
        {
            var list  = new TaskList();
            var task1 = list.Add(TwoFramesTask);
            var task2 = list.Add(TwoFramesTask);
            var tag   = new object();

            task2.Tag = tag;
            var task3 = list.Add(TwoFramesTask);

            list.StopByTag(tag);
            Assert.That(list.Contains(task1));
            Assert.That(list, Is.Not.Contains(task2));
            Assert.That(list.Contains(task3));
            Assert.That(task2.Completed);
        }
Beispiel #14
0
 public void startClient(TcpClient inClientSocket, List <Incapsulation.ConnectionUser> cList)
 {
     this._clientSocket = inClientSocket;
     this.ClientsList   = cList;
     TaskList.Add(new Task(doDataExchange));
     TaskList[TaskList.Count - 1].Start();
 }
        public ActionResult Index(List <string> ConcatInput, List <int> SumInput)
        {
            ConcatInput = ConcatInput ?? new List <string>();
            SumInput    = SumInput ?? new List <int>();

            var concatList = new TaskList <StringConcatTask>();
            var sumList    = new TaskList <SumIntegerTask>();

            concatList.Add(new StringConcatTask
            {
                StringList = ConcatInput
            });

            sumList.Add(new SumIntegerTask
            {
                IntegerList = SumInput
            });

            concatList.PerformListTasks();
            sumList.PerformListTasks();

            return(View(new IndexVm {
                ConcatInput = ConcatInput,
                SumInput = SumInput,
                ConcatResult = concatList[0].ConcatResult,
                SumResult = sumList[0].SumResult
            }));
        }
Beispiel #16
0
        public Task SessionPost([FromBody] Task task)
        {
            Console.WriteLine("POSTING SOME DATA");
            TaskList.Add(task);

            return(task);
        }
Beispiel #17
0
        public void StopByPredicateTest()
        {
            var    list     = new TaskList();
            var    task1    = list.Add(TwoFramesTask);
            var    task2    = list.Add(TwoFramesTask);
            Action updating = () => { };

            task2.Updating = updating;
            var task3 = list.Add(TwoFramesTask);

            list.Stop(t => t.Updating == updating);
            Assert.That(list.Contains(task1));
            Assert.That(list, Is.Not.Contains(task2));
            Assert.That(list.Contains(task3));
            Assert.That(task2.Completed);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            if (InPreSolve)
            {
                // You must place "RunCount == 1" here,
                // because RunCount is reset when "InPreSolve" becomes "false"
                if (RunCount == 1)
                {
                    source = new CancellationTokenSource();
                }

                GH_SpeckleBase item = null;
                DA.GetData(0, ref item);
                var task = Task.Run(() => DoWork(item, DA), source.Token);
                TaskList.Add(task);
                return;
            }

            if (source.IsCancellationRequested || !GetSolveResults(DA, out var data))
            {
                DA.AbortComponentSolution(); // You must abort the `SolveInstance` iteration
                return;
            }

            DA.SetData(0, data);
        }
Beispiel #19
0
        public override TaskList GetTask()
        {
            //string sql = "SELECT * FROM " + headtable + " WHERE operflag = 0 ";

            string sql = " SELECT distinct T.* FROM " + headtable + " T WITH(NOLOCK) ";

            sql += " INNER JOIN " + bodytable + " B WITH(NOLOCK) ON T.id = B.id  ";
            sql += " INNER JOIN MES_CQ_RdRecords11 MB WITH(NOLOCK) ON MB.MoCode = B.MoCode ";
            sql += " INNER JOIN MES_CQ_RdRecord11 MT WITH(NOLOCK) ON MT.id = MB.id  AND MT.operflag = 1  and T.opertype = MT.opertype and T.operflag = 0";

            string    curid = "";
            DataTable dt    = new DataTable();

            dt = DbHelperSQL.Query(sql).Tables[0];
            if (null == dt || dt.Rows.Count == 0)
            {
                return(null);
            }
            TaskList tl = new TaskList();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                Task        t = new Task();
                VoucherType v = new VoucherType();
                v.SourceCardNo = "MO21";
                //v.SourceVoucherNo = dt.Rows[i][""].ToString();
                v.CardNo      = cardNo;
                v.VoucherName = "产成品入库单";
                t.VouchType   = v;
                t.taskType    = 0; //MES接口任务
                t.OperType    = (int)dt.Rows[i]["OperType"];
                try
                {
                    t.id = dt.Rows[i]["id"].ToString();  //int.Parse(dt.Rows[i]["id"].ToString());
                }
                catch (Exception ee)
                {
                    BLL.Common.ErrorMsg(SysInfo.productName, "id 值出错!");
                }
                try
                {
                    t.OperType = int.Parse(dt.Rows[i]["opertype"].ToString());
                }
                catch (Exception ee)
                {
                    BLL.Common.ErrorMsg(SysInfo.productName, "opertype 值出错!");
                }
                tl.Add(t);
                curid += "'" + t.id + "',";
                break;
            }
            if (!string.IsNullOrEmpty(curid))
            {
                curid = curid.Substring(0, curid.Length - 1);
                string[] ids  = curid.Split(',');
                string   msql = " update " + headtable + " set " + taskStatusflagColName + " = 2 where id in (" + ids[0] + ") ";
                DbHelperSQL.ExecuteSql(msql);
            }
            return(tl);
        }
Beispiel #20
0
        private void ToggleComplete(Task task)
        {
            //Ensure an empty task can not be completed.
            if (task.Body.Trim() == string.Empty)
            {
                return;
            }

            var newTask = new Task(task.Raw);

            newTask.Completed = !newTask.Completed;

            try
            {
                if (User.Default.AutoArchive && newTask.Completed)
                {
                    if (User.Default.ArchiveFilePath.IsNullOrEmpty())
                    {
                        throw new Exception("You have enabled auto-archiving but have not specified an archive file.\nPlease go to File -> Options and disable auto-archiving or specify an archive file");
                    }

                    var archiveList = new TaskList(User.Default.ArchiveFilePath);
                    archiveList.Add(newTask);
                    _taskList.Delete(task);
                }
                else
                {
                    _taskList.Update(task, newTask);
                }
            }
            catch (Exception ex)
            {
                ex.Handle("An error occurred while updating the task's completed status");
            }
        }
Beispiel #21
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            List <Curve> interiorPartitions;
            Plane        plane = Plane.Unset;

            try
            {
                if (InPreSolve)
                {
                    rectangles         = new List <Rectangle3d>();
                    interiorPartitions = new List <Curve>();

                    DA.GetData(IN_AutoColor, ref autoColor);
                    DA.GetData(IN_plane, ref plane);
                    if (!DA.GetDataList(IN_rects, rectangles))
                    {
                        return;
                    }
                    DA.GetDataList(IN_partitions, interiorPartitions);


                    _plan = new SmartPlan(rectangles, interiorPartitions, plane);


                    Task <SolveResults> task = Task.Run(() => ComputeMSP(_plan), CancelToken);
                    TaskList.Add(task);
                    return;
                }

                if (!GetSolveResults(DA, out SolveResults result))
                {
                    rectangles         = new List <Rectangle3d>();
                    interiorPartitions = new List <Curve>();

                    DA.GetData(IN_AutoColor, ref autoColor);
                    DA.GetData(IN_plane, ref plane);
                    DA.GetDataList(IN_rects, rectangles);
                    DA.GetDataList(IN_partitions, interiorPartitions);

                    _plan  = new SmartPlan(rectangles, interiorPartitions, plane);
                    result = ComputeMSP(_plan);
                    _plan  = result.Value;
                }


                if (result != null)
                {
                    _mspMetric    = _plan.getMSP();
                    _rawMspMetric = _plan.getMSPRaw();
                    DA.SetDataList(OUT_mspMetric, _mspMetric);
                    DA.SetDataList(OUT_mspRawMetric, _rawMspMetric);
                    DA.SetDataTree(OUT_paths, _plan.pathCurves);
                }
            }
            catch (Exception e)
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Error, e.ToString());
            }
        }
Beispiel #22
0
 public void AddUserDefinedTask(string task)
 {
     if (UserDefinedTasks.Add(task))
     {
         TaskList.Add(task);
         OnPropertyChanged("Tasks");
     }
 }
Beispiel #23
0
        public void TestAddCompleted()
        {
            var list = new TaskList(1);
            var task = Task.FromResult(42);

            list.Add(task);
            new Action(() => list.WaitAll()).Should().NotThrow();
        }
 private void newTaskAdded(ToDoTask item)
 {
     if (item != null)
     {
         TaskList.Add(item);
         MessageBox.Show("Added task " + item.Title);
     }
 }
Beispiel #25
0
 private void AddTasksFromService()
 {
     TaskList.Clear();
     foreach (var task in TaskService.GetTasks())
     {
         TaskList.Add(task);
     }
 }
Beispiel #26
0
        public Mything()
        {
            var taskList = new TaskList("");

            taskList.Add("do new thing");

            taskList.SetTitle("");
        }
        public void AddTask()
        {
            TaskClass newClass = new TaskClass();

            newClass.TaskName = "NewTask";
            newClass.TaskDate = DateTime.Now.ToShortDateString();
            newClass.TaskTime = DateTime.Now.ToShortTimeString();
            TaskList.Add(newClass);
        }
Beispiel #28
0
 /// <summary>
 /// タスクを追加する
 /// </summary>
 /// <param name="item">追加するタスク</param>
 public void AddTask(TaskItem item)
 {
     TaskList.Add(item);
     // これが1個めなら入れておく
     if (TaskList.Count == 1)
     {
         Task = TaskList[0];
     }
 }
Beispiel #29
0
        public void UpdateNestedTest()
        {
            var list = new TaskList();

            list.Add(UpdateNestedTestTask(list));
            list.Update(0);
            list.Update(0);
            Assert.Fail("Task haven't called Assert.Pass() on second Update(). Possible nested Update() call.");
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            if (InPreSolve)
            {
                DA.DisableGapLogic();
                var speckleObj = new GH_SpeckleBase();
                var key        = "";
                DA.GetData(0, ref speckleObj);
                DA.GetData(1, ref key);
                if (DA.Iteration == 0)
                {
                    Tracker.TrackPageview("objects", "valueByKey");
                }

                var @base = speckleObj?.Value;
                var task  = Task.Run(() => DoWork(@base, key, CancelToken));
                TaskList.Add(task);
                return;
            }

            if (!GetSolveResults(DA, out object value))
            {
                // No result could be obtained.
                return;
            }

            // Report all conversion errors as warnings
            if (Converter != null)
            {
                foreach (var error in Converter.Report.ConversionErrors)
                {
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Warning,
                                      error.Message + ": " + error.InnerException?.Message);
                }
                Converter.Report.ConversionErrors.Clear();
            }

            switch (value)
            {
            case null:
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Key not found in object");
                break;

            case IList <object> list:
            {
                var ghGoos = list.Select(GH_Convert.ToGoo).ToList();
                DA.SetDataList(0, ghGoos);
                break;
            }

            default:
                Params.Output[0].Access = GH_ParamAccess.item;
                DA.SetData(0, GH_Convert.ToGoo(value));
                break;
            }
        }
Beispiel #31
0
 public void Activate(TaskList tasks)
 {
     if (activated == false)
     {
         activated = true;
         tasks.Add(autosaveBackup);
         Project.Opening        += OnProjectOpening;
         Project.DocumentSaving += OnDocumentSaving;
     }
 }
		public void Add_ToCollection()
		{
			var task = new Task("(B) Add_ToCollection +test @task");

			var tl = new TaskList(_testDataPath);

			List<Task> tasks = tl.ToList();
			tasks.Add(task);

			tl.Add(task);

			List<Task> newTasks = tl.ToList();

			Assert.AreEqual(tasks.Count, newTasks.Count);

			for (int i = 0; i < tasks.Count; i++)
				Assert.AreEqual(tasks[i].ToString(), newTasks[i].ToString());
		}
        TaskList GetRunningTasks()
        {
            var tl = new TaskList();
            var processlist = Process.GetProcesses();

            foreach (Process p in processlist)
            {
                var t = new Task();
                t.Name = p.ProcessName;
                t.ProcessId = p.Id;
                t.PrivateMemory = p.PrivateMemorySize64;
                t.WorkingSet = p.WorkingSet64;
                //t.ProcessorTime = p.TotalProcessorTime; // access denied
                tl.Add(t);
            }

            return tl;
        }
		public void Add_ToFile()
		{
			// Create a copy of test data so we can leave the original alone
			string tempTaskFile = CreateTempTasksFile();

			List<string> fileContents = File.ReadAllLines(tempTaskFile).ToList();
			fileContents.Add("(B) Add_ToFile +test @task");

			var task = new Task(fileContents.Last());
			var tl = new TaskList(tempTaskFile);
			tl.Add(task);
			tl.SaveTasks(tempTaskFile);

			string[] newFileContents = File.ReadAllLines(tempTaskFile);
			CollectionAssert.AreEquivalent(fileContents, newFileContents);

			// Clean up
			File.Delete(tempTaskFile);
		}
 internal static TaskList gatTaskList(HttpResponseMessage responce)
 {
     var taskList = new TaskList();
     var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, object>>(responce.Content.ReadAsStringAsync().Result);
     if (jsonObj.ContainsKey("task"))
     {
         var tasksArray = JsonConvert.DeserializeObject<List<object>>(jsonObj["task"].ToString());
         foreach(var taskObj in tasksArray)
         {
             var task = new ProjectTask();
             task = JsonConvert.DeserializeObject<ProjectTask>(taskObj.ToString());
             taskList.Add(task);
         }
     }
     if (jsonObj.ContainsKey("page_context"))
     {
         var pageContext = new PageContext();
         pageContext = JsonConvert.DeserializeObject<PageContext>(jsonObj["page_context"].ToString());
         taskList.page_context = pageContext;
     }
     return taskList;
 }
		public void Add_To_Empty_File()
		{
			// v0.3 and earlier contained a bug where a blank task was added
			string tempTaskFile = CreateTempTasksFile();
			File.WriteAllLines(tempTaskFile, new string[] {}); // empties the file

			var tl = new TaskList(tempTaskFile);
			tl.Add(new Task("A task"));

			Assert.AreEqual(1, tl.Count());

			// Clean up
			File.Delete(tempTaskFile);
		}
		/// <summary>
		/// Initializes a new instance of the MainViewModel class.
		/// </summary>
		public MainViewModel(PrimaryTaskFileService taskFileService, ArchiveTaskFileService archiveFileService, ApplicationSettings applicationSettings)
		{
		    _applicationSettings = applicationSettings;

		    if (IsInDesignMode)
		    {
		        // Code runs in Blend --> create design time data.
		        TaskList = new TaskList
		        {
		            new Task("A", null, null,
		                "This is a designer task that might be really long the quick brown fox jumped over the lazy dogs"),
		            new Task("", null, null, "This is a designer task2"),
		            new Task("", null, null,
		                "This is a designer task3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
		        };

		        var b = new Task("B", null, null, "This is a designer task4", DateTime.Now.AddDays(-1), null, false, null);
		        b.ToggleCompleted();
		        TaskList.Add(b);
		        TaskList.Add(new Task("C", null, null, "This is a designer task5"));

		        TaskList.Add(new Task("This task has two contexts @home @work"));
		        TaskList.Add(new Task("This task has two projects +planvacation +fixstove"));
		        TaskList.Add(new Task("This task has one of each @home +fixstove"));
		        TaskList.Add(new Task("")); // Blank task line

		        SelectedTask = TaskList[3];
		        ViewTask();
		    }
			else
			{
				// Code runs "for real"
				WireupTaskFileServices(taskFileService, archiveFileService);

				Messenger.Default.Register<DrillDownMessage>(this, Filter);
			    Messenger.Default.Register<ApplicationStartedMessage>(this, message =>
			        {
                        LocalHasChanges = _taskFileService.LocalHasChanges;

			            if(StartupSyncCommand.CanExecute(null))
			            {
			                StartupSyncCommand.Execute(null);
			            }
			        });

				WireUpCommands();
			}
		}
		public void Update_InCollection()
		{
			var task = new Task("(B) Update_InCollection +test @task");

			var tl = new TaskList(_testDataPath);
			tl.Add(task);

			var task2 = new Task(task.Raw);
			task2.ToggleCompleted();

			tl.Update(task, task2);

			Task newTask = tl.Last();
			Assert.IsTrue(newTask.Completed);
		}
		public void ToggleComplete_On_InCollection()
		{
			var task = new Task("(B ToggleComplete_On_InCollection +test @task");
			var tl = new TaskList(_testDataPath);
			tl.Add(task);

			task = tl.Last();

			task.ToggleCompleted();

			task = tl.Last();

			Assert.IsTrue(task.Completed);
		}
		public void ToggleComplete_Off_InCollection()
		{
			// Not complete - doesn't include completed date
			var task = new Task("X (B) ToggleComplete_Off_InCollection +test @task");
			var tl = new TaskList(_testDataPath);
			tl.Add(task);

			task = tl.Last();

			task.ToggleCompleted();

			task = tl.Last();

			Assert.IsTrue(task.Completed);

			var task2 = new Task("X 2011-02-25 ToggleComplete_Off_InCollection +test @task");

			tl.Add(task2);

			task = tl.Last();

			task.ToggleCompleted();

			task = tl.Last();

			Assert.IsFalse(task.Completed);
		}
		public void Save_To_Stream()
		{
			string tempTaskFile = CreateTempTasksFile();

			var tl = new TaskList();

			using (FileStream fs = File.OpenRead(tempTaskFile))
			{
				tl.LoadTasks(fs);
			}

			tl.Add(new Task("This task should end up in both lists"));

			string tempTaskFileCopy = CreateTempTasksFile();

			using (FileStream fs = File.OpenWrite(tempTaskFileCopy))
			{
				tl.SaveTasks(fs);
			}

			var tl2 = new TaskList(tempTaskFileCopy);

			Assert.AreEqual(tl.Count, tl2.Count);
		}
		public void ObservableChanges()
		{
			var tl = new TaskList();

			bool fired = false;

			tl.CollectionChanged += (sender, e) => { fired = true; };

			tl.LoadTasks(_testDataPath);

			Assert.True(fired);
			fired = false;

			tl.Add(new Task("T", null, null, "Test task for observablecollection event firing"));

			Assert.True(fired);
			fired = false;

			tl[0].PropertyChanged += (sender, e) => { fired = true; };

			tl[0].Append("Test append for propertychanged event firing");

			Assert.True(fired);
		}
 public static TaskList<ScheduleHistory> GetScheduleQueue()
 {
     var c = new TaskList<ScheduleHistory>();
     try
     {
         using (ScheduleQueue.GetReadLock(LockTimeout))
         {
             foreach (ScheduleHistory item in ScheduleQueue)
             {
                 c.Add(item);
             }
         }
         return c;
     }
     catch (ApplicationException ex)
     {
         Interlocked.Increment(ref _readerTimeouts);
         ErrorLogger.SchedulerProcessException(ex);
     }
     return c;
 }