public async Task ModelU002EPossibleSeasons_gets_SeasonId_from_Route()
        {
            var match = new Stoolball.Matches.Match
            {
                StartTime = DateTime.UtcNow.AddHours(1),
                Season    = new Season {
                    Competition = new Competition {
                        CompetitionName = "Example competition", CompetitionRoute = "/competitions/example"
                    }, SeasonRoute = "/competitions/example/2021"
                },
                MatchRoute = "/matches/example"
            };
            var matchDataSource = new Mock <IMatchDataSource>();

            matchDataSource.Setup(x => x.ReadMatchByRoute(It.IsAny <string>())).ReturnsAsync(match);

            var season = new Season {
                SeasonId = Guid.NewGuid(), Competition = new Competition {
                    CompetitionName = "Example competition", CompetitionRoute = "/competitions/example"
                }, SeasonRoute = "/competitions/example/2021"
            };
            var seasonDataSource = new Mock <ISeasonDataSource>();

            seasonDataSource.Setup(x => x.ReadSeasonByRoute(It.IsAny <string>(), true)).Returns(Task.FromResult(season));

            var helper = new Mock <IEditMatchHelper>();

            helper.Setup(x => x.PossibleSeasonsAsListItems(It.IsAny <IEnumerable <Season> >())).Returns((IEnumerable <Season> x) => new List <SelectListItem> {
                new SelectListItem {
                    Value = season.SeasonId.ToString()
                }
            });

            var matchAuthorizationPolicy = new Mock <IAuthorizationPolicy <Stoolball.Matches.Match> >();

            matchAuthorizationPolicy.Setup(x => x.IsAuthorized(match)).Returns(new Dictionary <AuthorizedAction, bool>());
            var competitionAuthorizationPolicy = new Mock <IAuthorizationPolicy <Competition> >();

            competitionAuthorizationPolicy.Setup(x => x.IsAuthorized(match.Season.Competition)).Returns(new Dictionary <AuthorizedAction, bool> {
                { AuthorizedAction.EditCompetition, false }
            });

            using (var controller = new TestController(matchDataSource.Object, seasonDataSource.Object, helper.Object, new Uri("https://example.org/matches/example-match"), UmbracoHelper,
                                                       matchAuthorizationPolicy.Object, competitionAuthorizationPolicy.Object))
            {
                var result = await controller.Index(new ContentModel(Mock.Of <IPublishedContent>())).ConfigureAwait(false);

                Assert.Equal(season.SeasonId.ToString(), ((IEditMatchViewModel)((ViewResult)result).Model).PossibleSeasons.First().Value);
            }
        }
        public async Task Route_matching_match_in_the_future_returns_EditLeagueMatchViewModel()
        {
            var season = new Season {
                Competition = new Competition {
                    CompetitionName = "Example competition", CompetitionRoute = "/competitions/example"
                }, SeasonRoute = "/competitions/example/2021"
            };
            var match = new Stoolball.Matches.Match
            {
                StartTime  = DateTime.UtcNow.AddHours(1),
                Season     = season,
                MatchRoute = "/matches/example"
            };
            var matchDataSource = new Mock <IMatchDataSource>();

            matchDataSource.Setup(x => x.ReadMatchByRoute(It.IsAny <string>())).ReturnsAsync(match);

            var seasonDataSource = new Mock <ISeasonDataSource>();

            seasonDataSource.Setup(x => x.ReadSeasonByRoute(It.IsAny <string>(), true)).Returns(Task.FromResult(season));

            var helper = new Mock <IEditMatchHelper>();

            var matchAuthorizationPolicy = new Mock <IAuthorizationPolicy <Stoolball.Matches.Match> >();

            matchAuthorizationPolicy.Setup(x => x.IsAuthorized(match)).Returns(new Dictionary <AuthorizedAction, bool>());
            var competitionAuthorizationPolicy = new Mock <IAuthorizationPolicy <Competition> >();

            competitionAuthorizationPolicy.Setup(x => x.IsAuthorized(match.Season.Competition)).Returns(new Dictionary <AuthorizedAction, bool> {
                { AuthorizedAction.EditCompetition, false }
            });

            using (var controller = new TestController(matchDataSource.Object, seasonDataSource.Object, helper.Object, new Uri("https://example.org/matches/example-match"), UmbracoHelper,
                                                       matchAuthorizationPolicy.Object, competitionAuthorizationPolicy.Object))
            {
                var result = await controller.Index(new ContentModel(Mock.Of <IPublishedContent>())).ConfigureAwait(false);

                Assert.IsType <EditLeagueMatchViewModel>(((ViewResult)result).Model);
            }
        }