public async Task TestEditOtherUsersTask() { using (var context = new SocialBackendContext(options)) { // Given i = 0; // IQueryable <Todo> _todo = from t in context.Todo orderby t.id ascending select t; var dbTodo = await _todo.AsNoTracking().FirstOrDefaultAsync(); Todo updatedTodo = new Todo() { id = dbTodo.id + 1, task = tasks[i], complete = completes[i], dueDate = dueDates[i] }; //When ICookieService fakeCookie = new FakeCookieService(); TodoesController todoController = new TodoesController(context, fakeCookie); var result = await todoController.UpdateTask(dbTodo.id + 1, updatedTodo) as IActionResult; // Then Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(UnauthorizedResult)); Assert.AreEqual(2, context.Todo.Count()); } }
public async Task TestNullCookiePut() { using (var context = new SocialBackendContext(options)) { // Given i = 2; // task does not currently exists in db Todo updatedTodo = new Todo() { id = (await context.Todo.AsNoTracking().FirstAsync()).id, task = tasks[i], complete = completes[i], dueDate = dueDates[i] }; //When ICookieService fakeCookie = new FakeCookieService(); TodoesController todoController = new TodoesController(context, fakeCookie); var result = await todoController.UpdateTask((await context.Todo.AsNoTracking().FirstAsync()).id, updatedTodo) as IActionResult; // Then Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(UnauthorizedResult)); Assert.AreEqual(2, context.Todo.Count()); } }