public void RetrieveASeasonViewInTheRepo() { List <SeasonTableViewModel> seasonView = CreateSeasonList(); var mock = new Mock <ISeasonTableViewRepository>(MockBehavior.Strict); mock.As <ISeasonTableViewRepository>().Setup(m => m.GetAll(null)) .Returns(Task.FromResult((IEnumerable <SeasonTableViewModel>)seasonView)); // Creating the controller which we want to create SeasonTableViewController controller = new SeasonTableViewController(mock.Object); // configuring the context for the controler fakeContext(controller); HttpResponseMessage response = controller.GetAll(null).Result; Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); var objectContent = response.Content as ObjectContent; // we should retrieve the season view 0 Assert.AreEqual(seasonView, (IEnumerable <SeasonTableViewModel>)objectContent.Value); Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); }
public void RetrieveNothingForTheSeasonInTheRepo() { var mock = new Mock <ISeasonTableViewRepository>(MockBehavior.Strict); mock.As <ISeasonTableViewRepository>().Setup(m => m.GetAll(null)) .Returns(Task.FromResult((IEnumerable <SeasonTableViewModel>)null)); // Creating the controller which we want to create SeasonTableViewController controller = new SeasonTableViewController(mock.Object); // configuring the context for the controler fakeContext(controller); HttpResponseMessage response = controller.GetAll(null).Result; Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); }