Exemplo n.º 1
0
        public void TestFetchTaskByIdWithNullUserFromTheDatabase()
        {
            TaskBusiness mockTaskBusiness = new TaskBusiness(_mockContext.Object);

            int taskId = 5;

            User mockUser = null;

            Assert.Catch(() => mockTaskBusiness.FetchTaskById(taskId, mockUser), "Non existent task was fetched!");
        }
Exemplo n.º 2
0
        public void TestFetchNonExistentTaskByIdFromTheDatabase()
        {
            TaskBusiness mockTaskBusiness = new TaskBusiness(_mockContext.Object);
            UserBusiness mockUserBusiness = new UserBusiness(_mockContext.Object);

            int    taskId       = 5;
            string userName     = "******";
            string passwordHash = "passwordHash";

            User mockUser = mockUserBusiness.FetchUser(userName, passwordHash);

            Assert.Catch(() => mockTaskBusiness.FetchTaskById(taskId, mockUser), "Non existent task was fetched!");
        }
Exemplo n.º 3
0
        public void TestFetchTaskByIdFromTheDatabase()
        {
            TaskBusiness mockTaskBusiness = new TaskBusiness(_mockContext.Object);
            UserBusiness mockUserBusiness = new UserBusiness(_mockContext.Object);

            int    taskId       = 2;
            string userName     = "******";
            string passwordHash = "passwordHash";

            User mockUser = mockUserBusiness.FetchUser(userName, passwordHash);

            Task mockTask = mockTaskBusiness.FetchTaskById(taskId, mockUser);

            Assert.AreEqual(taskId, mockTask.TaskId, "Wrong task was fetched!");
        }
Exemplo n.º 4
0
        public void TestCompleteTaskFromTheDatabase()
        {
            TaskBusiness mockTaskBusiness = new TaskBusiness(_mockContext.Object);
            UserBusiness mockUserBusiness = new UserBusiness(_mockContext.Object);


            string userName     = "******";
            string passwordHash = "passwordHash";

            User mockUser = mockUserBusiness.FetchUser(userName, passwordHash);

            Task mockTask = new Task()
            {
                TaskId = 3, Date = DateTime.Now, Name = "name", IsDone = false, UserId = 1
            };

            mockTaskBusiness.AddTask(mockTask);

            mockTaskBusiness.CompleteTask(mockTask.TaskId, mockUser);

            mockTask = mockTaskBusiness.FetchTaskById(mockTask.TaskId, mockUser);

            Assert.AreEqual(mockTask.IsDone, true, "Wrong task was fetched!");
        }