예제 #1
0
        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));
        }
예제 #2
0
        public void RenderDefaultView_WhenInvoked()
        {
            // arrange
            var teamsService = new Mock <ITeamService>();
            var controller   = new TeamsGridController(teamsService.Object);

            // act & assert
            controller.WithCallTo(c => c.Index())
            .ShouldRenderDefaultView();
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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));
        }