public void CallPlayerServiceUpdateMethodWithCorrectMappedPlayerDateModel_WhenPassedModelParamIsNotNull() { // arrange var leagueService = new Mock <IPlayerService>(); var playerViewModel = new GridPlayerViewModel() { FirstName = "someName" }; var mapService = new Mock <IMappingService>(); var playerDatamodel = new Player() { FirstName = "someName" }; mapService.Setup(c => c.Map <Player>(It.IsAny <Object>())) .Returns(playerDatamodel); MappingService.MappingProvider = mapService.Object; var controller = new PlayersGridController(leagueService.Object); // act controller.EditPlayer(playerViewModel); // assert leagueService.Verify(c => c.Update(playerDatamodel), Times.Once); }
public void ReturnJsonArrayWithTheEditedPlayer_WhenPassedModelParamIsNotNull() { // arrange var playerService = new Mock <IPlayerService>(); var playerVieWModel = new GridPlayerViewModel() { FirstName = "someName" }; var mapService = new Mock <IMappingService>(); var leagueDataModel = new Player() { FirstName = "someName" }; mapService.Setup(c => c.Map <Player>(It.IsAny <Object>())) .Returns(leagueDataModel); MappingService.MappingProvider = mapService.Object; var controller = new PlayersGridController(playerService.Object); // act controller.EditPlayer(playerVieWModel); // assert controller.WithCallTo(c => c.EditPlayer(playerVieWModel)) .ShouldReturnJson((data) => Assert.AreSame(data[0], playerVieWModel)); }
public void RenderDefaultView_WhenInvoked() { // arrange var playerService = new Mock <IPlayerService>(); var controller = new PlayersGridController(playerService.Object); // act & assert controller.WithCallTo(c => c.Index()) .ShouldRenderDefaultView(); }
public void ReturnJsonArrayWithDeletedTeam_WhenPassedModelParamIsNotNull() { // arrange var teamService = new Mock <IPlayerService>(); var playerViewModel = new GridPlayerViewModel() { FirstName = "someName" }; var controller = new PlayersGridController(teamService.Object); // act controller.DeletePlayer(playerViewModel); // assert controller.WithCallTo(c => c.DeletePlayer(playerViewModel)) .ShouldReturnJson((data) => Assert.AreSame(data[0], playerViewModel)); }