示例#1
0
        public void GetTasksByDateFromToTest_TwoResults()
        {
            FakeContext       mock = new FakeContext();
            FakeUserInterface fakeUserInterface = new FakeUserInterface();
            TaskControl       ctrl = new TaskControl(mock, fakeUserInterface);
            ToDoTask          obj  = new ToDoTask();

            obj.Name = "test";
            obj.Date = new DateTime(2019, 2, 1);
            ToDoTask secondObj = new ToDoTask();

            secondObj.Name = "test2";
            secondObj.Date = new DateTime(2019, 5, 3);
            ToDoTask ThirthObj = new ToDoTask();

            ThirthObj.Name = "test3";
            ThirthObj.Date = new DateTime(2019, 7, 10);

            ctrl.AddAsync(obj).Wait();
            ctrl.AddAsync(secondObj).Wait();
            ctrl.AddAsync(ThirthObj).Wait();
            List <ToDoTask> result = ctrl.GetByDatesAsync(new DateTime(2019, 5, 3), new DateTime(2019, 7, 10)).Result.ToList();

            Assert.AreEqual(2, result.Count, "Count elements of lists are different");
        }
示例#2
0
        private async void LoadData()
        {
            try
            {
                taskControl = new TaskControl(new TaskContext(), this);

                if (InvokeRequired == false)
                {
                    this.grid.DataSource = await taskControl.GetByDatesAsync(this.dateFrom.Value, this.dateTo.Value);

                    return;
                }

                this.grid.Invoke(new Action(async delegate()
                {
                    this.grid.DataSource = await taskControl.GetByDatesAsync(this.dateFrom.Value, this.dateTo.Value);
                }));
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }
        }