public void ReturnCorrectPartialViewWithModel_WhenInvoked() { // arrange var fixtureService = new Mock <IFixtureService>(); var date = new DateTime(2012, 12, 12); var scoresController = new ScoresController(fixtureService.Object); var mappingProvider = new Mock <IMappingService>(); mappingProvider.Setup(c => c.Map <AvailableScoreViewModel>(It.IsAny <Object>())) .Returns(new AvailableScoreViewModel() { LeagueName = "someName" }); MappingService.MappingProvider = mappingProvider.Object; fixtureService.Setup(f => f.GetAvailableFixtures(date)).Returns(new List <Fixture>()); // act scoresController.ByDate(date); // assert scoresController.WithCallTo(c => c.ByDate(date)) .ShouldRenderPartialView(PartialViews.AvailableScoresPartial) .WithModel <IEnumerable <IGrouping <string, AvailableScoreViewModel> > >(); }
public void CallFixtureServiceGetAvailableFixtureWithCorrectDateParameter_WhenInvoked() { // arrange var fixtureService = new Mock <IFixtureService>(); var date = new DateTime(2012, 12, 12); var scoresController = new ScoresController(fixtureService.Object); var mappingProvider = new Mock <IMappingService>(); mappingProvider.Setup(c => c.Map <AvailableScoreViewModel>(It.IsAny <Object>())).Returns(new AvailableScoreViewModel() { LeagueName = "someName" }); MappingService.MappingProvider = mappingProvider.Object; fixtureService.Setup(f => f.GetAvailableFixtures(date)).Returns(new List <Fixture>()); // act scoresController.ByDate(date); // assert fixtureService.Verify(f => f.GetAvailableFixtures(date), Times.Once); }