Esempio n. 1
0
        public void TestListAllCompletedUserTasksFromTheDatabase()
        {
            TaskBusiness mockTaskBusiness = new TaskBusiness(_mockContext.Object);
            UserBusiness mockUserBusiness = new UserBusiness(_mockContext.Object);

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

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

            Task mockTask1 = new Task()
            {
                TaskId = 3, Date = DateTime.Now, Name = "name", IsDone = true, UserId = 1
            };
            Task mockTask2 = new Task()
            {
                TaskId = 4, Date = DateTime.Now, Name = "name", IsDone = true, UserId = 1
            };

            mockTaskBusiness.AddTask(mockTask1);
            mockTaskBusiness.AddTask(mockTask2);

            int count         = mockTaskBusiness.ListAllCompletedTasks(mockUser).Count();
            int expectedCount = mockTaskBusiness.GetPODbContext.Tasks.Where(x => x.UserId == mockUser.UserId && x.IsDone == true).ToList().Count();

            Assert.AreEqual(expectedCount, count, "Not all tasks were fetched!");
        }
Esempio n. 2
0
        public void TestListAllCompletedNullUserTasksFromTheDatabase()
        {
            TaskBusiness mockTaskBusiness = new TaskBusiness(_mockContext.Object);

            User mockUser = null;

            Assert.Catch(() => mockTaskBusiness.ListAllCompletedTasks(mockUser), "Null user completed tasks were fetched!");
        }