public void DeleteFailureLeagueInTheRepo() { var mock = new Mock <ILeagueRepository>(MockBehavior.Strict); // Creating the rules for mock, always send true in this case mock.As <ICRUDRepository <League, int, LeagueFilter> >().Setup(m => m.Remove(It.IsAny <int>())) .Returns(Task.FromResult(false)); var mockSeasonRepo = new Mock <ISeasonRepository>(MockBehavior.Strict); mockSeasonRepo.As <ICRUDRepository <Season, int, SeasonFilter> >().Setup(m => m.Get(It.IsAny <int>())) .Returns <int>(id => Task.FromResult(new Season())); // Creating the controller which we want to create LeagueController controller = new LeagueController(mock.Object, mockSeasonRepo.Object); // configuring the context for the controler fakeContext(controller); HttpResponseMessage response = controller.Delete(0).Result; // the result should say "HttpStatusCode.NotFound" Assert.AreEqual(response.StatusCode, HttpStatusCode.NotFound); }