Esempio n. 1
0
        public void GetTasksNotifications_TwoResults()
        {
            FakeContext       mock = new FakeContext();
            FakeUserInterface fakeUserInterface = new FakeUserInterface();
            TaskControl       ctrl = new TaskControl(mock, fakeUserInterface);
            ToDoTask          obj  = new ToDoTask();

            obj.Name = "test";
            obj.Date = DateTime.Now.AddDays(5);
            ToDoTask secondObj = new ToDoTask();

            secondObj.Name = "test2";
            secondObj.Date = DateTime.Now.AddDays(7);
            ToDoTask ThirthObj = new ToDoTask();

            ThirthObj.Name = "test3";
            ThirthObj.Date = DateTime.Now.AddDays(3);

            ctrl.AddAsync(obj).Wait();
            ctrl.AddAsync(secondObj).Wait();
            ctrl.AddAsync(ThirthObj).Wait();
            List <ToDoTask> result = ctrl.GetNotifications(5).Result.ToList();

            Assert.AreEqual(2, result.Count, "Count elements of lists are different");
        }
Esempio n. 2
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");
        }
Esempio n. 3
0
        public void RemoveByIDTest()
        {
            FakeContext       mock = new FakeContext();
            FakeUserInterface fakeUserInterface = new FakeUserInterface();
            TaskControl       ctrl = new TaskControl(mock, fakeUserInterface);
            ToDoTask          obj  = new ToDoTask();

            obj.Name = "test";

            ctrl.AddAsync(obj).Wait();
            ctrl.RemoveAsync(obj.ID).Wait();

            Assert.IsTrue(fakeUserInterface.isCalled);
            Assert.AreEqual(0, mock.ListOfTasks.Count, "Count elements of Tasks is incorrect");
        }
Esempio n. 4
0
        public void AddTest()
        {
            FakeContext       mock = new FakeContext();
            FakeUserInterface fakeUserInterface = new FakeUserInterface();
            TaskControl       ctrl = new TaskControl(mock, fakeUserInterface);
            ToDoTask          obj  = new ToDoTask();
            const string      NAME = "test";

            obj.Name = NAME;

            ctrl.AddAsync(obj).Wait();

            Assert.IsTrue(fakeUserInterface.isCalled);
            Assert.AreEqual(1, mock.ListOfTasks.Count, "Count elements of Tasks is incorrect");
            Assert.AreEqual(NAME, mock.ListOfTasks[0].Name, "Name of task is incorrect");
        }
Esempio n. 5
0
        public void AddTasksTest()
        {
            FakeContext       mock = new FakeContext();
            FakeUserInterface fakeUserInterface = new FakeUserInterface();
            TaskControl       ctrl = new TaskControl(mock, fakeUserInterface);
            ToDoTask          obj  = new ToDoTask();

            obj.Name = "test";
            ToDoTask secondObj = new ToDoTask();

            secondObj.Name = "test2";

            ctrl.AddAsync(obj).Wait();
            ctrl.AddAsync(secondObj).Wait();

            Assert.IsTrue(fakeUserInterface.isCalled);
            Assert.AreEqual(2, mock.ListOfTasks.Count, "Count elements of Tasks is incorrect");
            Assert.IsTrue(mock.ListOfTasks[0].Name != mock.ListOfTasks[1].Name, "Name of tasks are the same");
        }
Esempio n. 6
0
        public void GetAllTest()
        {
            FakeContext       mock = new FakeContext();
            FakeUserInterface fakeUserInterface = new FakeUserInterface();
            TaskControl       ctrl = new TaskControl(mock, fakeUserInterface);
            ToDoTask          obj  = new ToDoTask();

            obj.Name = "test";
            ToDoTask secondObj = new ToDoTask();

            secondObj.Name = "test2";

            ctrl.AddAsync(obj).Wait();
            ctrl.AddAsync(secondObj).Wait();
            fakeUserInterface.isCalled = false;
            List <ToDoTask> result = ctrl.GetAllAsync().Result.ToList();

            Assert.IsFalse(fakeUserInterface.isCalled);
            Assert.AreEqual(2, result.Count, "Count elements of lists are different");
        }
Esempio n. 7
0
        public void GetByNotExistingIDTest()
        {
            FakeContext       mock = new FakeContext();
            FakeUserInterface fakeUserInterface = new FakeUserInterface();
            TaskControl       ctrl = new TaskControl(mock, fakeUserInterface);
            const string      NAME = "test";
            ToDoTask          obj  = new ToDoTask();

            obj.Name = NAME;
            ToDoTask secondObj = new ToDoTask();

            secondObj.Name = "test2";

            ctrl.AddAsync(obj).Wait();
            ctrl.AddAsync(secondObj).Wait();
            fakeUserInterface.isCalled = false;
            ToDoTask result = ctrl.GetAsync(-1).Result;

            Assert.IsFalse(fakeUserInterface.isCalled);
            Assert.AreEqual(null, result, "Objects are different");
        }