public async Task SaveAndUpdateSeason()
        {
            var championshipsList = new List <Championship> {
                new Championship {
                    Id = 1, Name = "Premier League"
                }
            };
            var seasonsList = new List <Season>();

            var mockChampionshipRepo = new Mock <IRepository <Championship> >();

            mockChampionshipRepo.Setup(r => r.Get(It.IsAny <int>())).Returns <int>(id => championshipsList.FirstOrDefault(c => c.Id == id));

            var mockSeasonRepo = new Mock <IRepository <Season> >();

            mockSeasonRepo.Setup(r => r.All()).Returns(seasonsList.AsQueryable());
            mockSeasonRepo.Setup(r => r.AddAsync(It.IsAny <Season>())).Callback <Season>(season => seasonsList.Add(new Season
            {
                Id           = 1,
                Name         = season.Name,
                Championship = season.Championship
            }));

            var seasonService = new SeasonService(mockSeasonRepo.Object, mockChampionshipRepo.Object);

            var seasonViewModel = new SeasonViewModel
            {
                Name           = "2020/21",
                ChampionshipId = 1
            };

            await seasonService.CreateAsync(seasonViewModel);

            var updatedViewModel = new SeasonViewModel
            {
                Id             = 1,
                Name           = "2020/21",
                ChampionshipId = 1
            };

            await seasonService.UpdateAsync(updatedViewModel);

            var savedSeason = seasonService.Get(1);

            Assert.Equal(1, savedSeason.Id);
            Assert.Equal("2020/21", savedSeason.Name);
        }
        public async Task SaveAndLoadSeason()
        {
            var championshipsList = new List <Championship> {
                new Championship {
                    Id = 1, Name = "Premier League"
                }
            };
            var seasonsList = new List <Season>();

            var mockChampionshipRepo = new Mock <IRepository <Championship> >();

            mockChampionshipRepo.Setup(r => r.Get(It.IsAny <int>())).Returns <int>(id => championshipsList.FirstOrDefault(c => c.Id == id));

            var mockSeasonRepo = new Mock <IRepository <Season> >();

            mockSeasonRepo.Setup(r => r.All()).Returns(seasonsList.AsQueryable());
            mockSeasonRepo.Setup(r => r.AddAsync(It.IsAny <Season>())).Callback <Season>(season => seasonsList.Add(season));
            mockSeasonRepo.Setup(r => r.Get(It.IsAny <int>())).Returns <int>(id => seasonsList.FirstOrDefault(c => c.Id == id));

            var seasonService = new SeasonService(mockSeasonRepo.Object, mockChampionshipRepo.Object);

            var seasonViewModel = new SeasonViewModel
            {
                Name             = "2020/21",
                ChampionshipId   = 1,
                ChampionshipName = "Premier League",
                Description      = "Premier League, Season 2020/21"
            };

            await seasonService.CreateAsync(seasonViewModel);

            var savedSeason     = seasonService.Get(10, false);
            var lastSavedSeason = seasonService.GetAll().LastOrDefault();

            Assert.Null(savedSeason);
            Assert.Equal("2020/21", lastSavedSeason.Name);
            Assert.Equal("Premier League, Season 2020/21", seasonViewModel.Description);
            Assert.Equal("Premier League", seasonViewModel.ChampionshipName);
            Assert.NotNull(lastSavedSeason.Championship);
        }