Exemple #1
0
        public void PassCorrectViewModelToPartialView_WhenEverythinHasPassedSuccessfully()
        {
            // arrange
            var fixtureService = new Mock <IFixtureService>();
            var playerService  = new Mock <IPlayerService>();

            var controller = new UpdateFixtureController(fixtureService.Object, playerService.Object);

            var targetFixture = new Fixture()
            {
                HomeTeam = new Team()
                {
                    Name = "someName"
                },
                Id = Guid.NewGuid(),
            };

            fixtureService.Setup(f => f.GetById(It.IsAny <Guid>())).Returns(targetFixture);
            playerService.Setup(p => p.GetAll(It.IsAny <Guid>())).Returns(new List <Player>());

            var mapSerivce = new Mock <IMappingService>();

            mapSerivce.Setup(m => m.Map <UpdatingFixturePlayerViewModel>(It.IsAny <Object>()))
            .Returns(new UpdatingFixturePlayerViewModel());

            MappingService.MappingProvider = mapSerivce.Object;

            // act
            controller.UpdateFixtureEvent("someName", targetFixture.Id);

            // assert
            controller.WithCallTo(c => c.UpdateFixtureEvent("someName", targetFixture.Id))
            .ShouldRenderPartialView(PartialViews.UpdateFixtureFormPartial)
            .WithModel <UpdateFixtureViewModel>(m => m.TeamId == targetFixture.HomeTeam.Id);
        }
Exemple #2
0
        public void CallTheCorrectPartialView_WhenInvoked()
        {
            // arrange
            var fixtureService = new Mock <IFixtureService>();
            var playerService  = new Mock <IPlayerService>();

            var controller = new UpdateFixtureController(fixtureService.Object, playerService.Object);

            var id = Guid.NewGuid();

            // act
            controller.UpdateFixtureStatus(id);

            // assert
            controller.WithCallTo(c => c.UpdateFixtureStatus(id))
            .ShouldRenderPartialView(PartialViews.UpdateFixtureStatusPartial);
        }
Exemple #3
0
        public void PassViewModelWithTheSameParameterId_WhenInvokedWithValidIdParam()
        {
            // arrange
            var fixtureService = new Mock <IFixtureService>();
            var playerService  = new Mock <IPlayerService>();

            var controller = new UpdateFixtureController(fixtureService.Object, playerService.Object);

            var id = Guid.NewGuid();

            // act
            controller.UpdateFixtureStatus(id);

            // assert
            controller.WithCallTo(c => c.UpdateFixtureStatus(id))
            .ShouldRenderPartialView(PartialViews.UpdateFixtureStatusPartial)
            .WithModel <UpdateFixtureStatusViewModel>(m => m.Id == id);
        }
        public void RedirectToScoresControllerAvalableScoresAction_WhenPassMathodParametersAreValid()
        {
            // arrange
            var fixtureService = new Mock <IFixtureService>();
            var playerService  = new Mock <IPlayerService>();

            var controller = new UpdateFixtureController(fixtureService.Object, playerService.Object);

            var id           = Guid.NewGuid();
            var fixtureModel = new UpdateFixtureViewModel()
            {
                Id = id, PlayerId = id, FixtureEvent = FixtureEventType.Penalty, Minute = 22
            };

            // act
            controller.UpdateFixtureEvent(id, fixtureModel);

            // assert
            controller.WithCallTo(c => c.UpdateFixtureEvent(id, fixtureModel))
            .ShouldRedirectTo <ScoresController>(sc => sc.AvailableScores());
        }
Exemple #5
0
        public void RedirectToScoresControllerAvailableScores_WhenInvokedWithValidParameters()
        {
            // arrange
            var fixtureService = new Mock <IFixtureService>();
            var playerService  = new Mock <IPlayerService>();

            var controller = new UpdateFixtureController(fixtureService.Object, playerService.Object);

            var id    = Guid.NewGuid();
            var model = new UpdateFixtureStatusViewModel()
            {
                Status = FixtureStatus.HalfTime
            };

            // act
            controller.UpdateFixtureStatus(id, model);

            // asset
            controller.WithCallTo(c => c.UpdateFixtureStatus(id, model))
            .ShouldRedirectTo <ScoresController>(sc => sc.AvailableScores());
        }