public void ReturnJsonArrayWithTheEditedTeam_WhenPassedModelParamIsNotNull() { // arrange var teamService = new Mock <ITeamService>(); var teamViewModel = new GridTeamViewModel() { Name = "someName" }; var mapService = new Mock <IMappingService>(); var teamDataModel = new Team() { Name = "someName" }; mapService.Setup(c => c.Map <Team>(It.IsAny <Object>())) .Returns(teamDataModel); MappingService.MappingProvider = mapService.Object; var controller = new TeamsGridController(teamService.Object); // act controller.EditTeam(teamViewModel); // assert controller.WithCallTo(c => c.EditTeam(teamViewModel)) .ShouldReturnJson((data) => Assert.AreSame(data[0], teamViewModel)); }
public void RenderDefaultView_WhenInvoked() { // arrange var teamsService = new Mock <ITeamService>(); var controller = new TeamsGridController(teamsService.Object); // act & assert controller.WithCallTo(c => c.Index()) .ShouldRenderDefaultView(); }
public void CallTeamServiceDeleteMethodWithCorrectId() { // arrange var teamService = new Mock <ITeamService>(); var teamViewModel = new GridTeamViewModel() { Name = "someName", Id = Guid.NewGuid(), LogoUrl = "SomeLogo" }; var controller = new TeamsGridController(teamService.Object); // act controller.DeleteTeam(teamViewModel); // assert teamService.Verify(c => c.Delete(teamViewModel.Id), Times.Once); }
public void CallTeamServiceUpdateMethodWithCorrectParametersDateModel_WhenPassedModelParamIsNotNull() { // arrange var teamService = new Mock <ITeamService>(); var teamViewModel = new GridTeamViewModel() { Name = "someName", Id = Guid.NewGuid(), LogoUrl = "SomeLogo" }; var mapService = new Mock <IMappingService>(); var controller = new TeamsGridController(teamService.Object); // act controller.EditTeam(teamViewModel); // assert teamService.Verify(c => c.Update(teamViewModel.Id, teamViewModel.Name, teamViewModel.LogoUrl), Times.Once); }
public void ReturnJsonArrayWithDeletedTeam_WhenPassedModelParamIsNotNull() { // arrange var teamService = new Mock <ITeamService>(); var teamViewModel = new GridTeamViewModel() { Name = "someName" }; var controller = new TeamsGridController(teamService.Object); // act controller.DeleteTeam(teamViewModel); // assert controller.WithCallTo(c => c.DeleteTeam(teamViewModel)) .ShouldReturnJson((data) => Assert.AreSame(data[0], teamViewModel)); }