public void ReturnJsonArrayWithTheEditedCountry_WhenPassedModelParamIsNotNull() { // arrange var leagueService = new Mock <ILeagueService>(); var leagueViewModel = new GridLeagueViewModel() { Name = "someName" }; var mapService = new Mock <IMappingService>(); var leagueDataModel = new League() { Name = "someName" }; mapService.Setup(c => c.Map <League>(It.IsAny <Object>())) .Returns(leagueDataModel); MappingService.MappingProvider = mapService.Object; var controller = new LeaguesGridController(leagueService.Object); // act controller.EditLeague(leagueViewModel); // assert controller.WithCallTo(c => c.EditLeague(leagueViewModel)) .ShouldReturnJson((data) => Assert.AreSame(data[0], leagueViewModel)); }
public void CallCountryServiceUpdateMethodWithCOrrectMappedCountryDateModel_WhenPassedModelParamIsNotNull() { // arrange var leagueService = new Mock <ILeagueService>(); var leagueViewModel = new GridLeagueViewModel() { Name = "someName" }; var mapService = new Mock <IMappingService>(); var leagueDataModel = new League() { Name = "someName" }; mapService.Setup(c => c.Map <League>(It.IsAny <Object>())) .Returns(leagueDataModel); MappingService.MappingProvider = mapService.Object; var controller = new LeaguesGridController(leagueService.Object); // act controller.EditLeague(leagueViewModel); // assert leagueService.Verify(c => c.Update(leagueDataModel), Times.Once); }