public void TestCompleteNonExistentTaskFromDatabase() { TaskBusiness mockTaskBusiness = new TaskBusiness(_mockContext.Object); UserBusiness mockUserBusiness = new UserBusiness(_mockContext.Object); int taskId = 3; string userName = "******"; string passwordHash = "passwordHash"; User mockUser = mockUserBusiness.FetchUser(userName, passwordHash); Assert.Catch(() => mockTaskBusiness.CompleteTask(taskId, mockUser), "Non existent task was completed!"); }
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!"); }