コード例 #1
0
        public void GetTeamsByIdCompetition_TeamsForThatCompetitionExist_ReturnsTeamList()
        {
            var competition = CompetitionCommands.SaveCompetition(new Competition {
                Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(100)
            }, Context);
            var serie1 = SerieCommands.SaveSerie(new Serie {
                Description = RandomUtil.GetRandomString(), IdCompetition = competition.IdCompetition
            }, Context);
            var serie2 = SerieCommands.SaveSerie(new Serie {
                Description = RandomUtil.GetRandomString(), IdCompetition = competition.IdCompetition
            }, Context);

            TeamCommands.SaveTeam(new Team {
                Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(), IdSerie = serie1.IdSerie
            }, Context);
            TeamCommands.SaveTeam(new Team {
                Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(), IdSerie = serie1.IdSerie
            }, Context);
            TeamCommands.SaveTeam(new Team {
                Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(), IdSerie = serie2.IdSerie
            }, Context);
            TeamCommands.SaveTeam(new Team {
                Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(), IdSerie = serie2.IdSerie
            }, Context);

            var teams = TeamQueries.GetTeamsByIdCompetition(Context, competition.IdCompetition);

            Assert.IsNotNull(teams);
            Assert.AreEqual(4, teams.Count);
        }
コード例 #2
0
        public override void SaveEntity_EntityIsNew_EntityIsCreated()
        {
            var competition = CreateCompetition();
            var serie       = SerieCommands.SaveSerie(new Serie {
                Description = RandomUtil.GetRandomString(), IdCompetition = competition.IdCompetition
            }, Context);

            Assert.IsNotNull(serie.IdSerie);
        }
コード例 #3
0
        public void GetSeriesByPartOfDescription_ReturnsListOfSeries()
        {
            var description = RandomUtil.GetRandomString(30);

            SerieCommands.SaveSerie(new Serie {
                Description = description
            }, Context);
            var series = SerieQueries.GetSeriesByPartOfDescription(Context,
                                                                   description.Substring(RandomUtil.GetRandomNumber(1), RandomUtil.GetRandomNumber(1) + 1));

            Assert.IsNotNull(series);
            Assert.IsNotNull(series.FirstOrDefault(s => s.Description == description));
        }
コード例 #4
0
        public override void GetEntityById_EntityDoesExist_ReturnsEntity()
        {
            var competition = CompetitionCommands.SaveCompetition(new Competition {
                Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(150)
            }, Context);
            var serie = SerieCommands.SaveSerie(
                new Serie {
                Description = RandomUtil.GetRandomString(), IdCompetition = competition.IdCompetition
            },
                Context);

            Assert.IsNotNull(serie.IdSerie);
        }
コード例 #5
0
        public void GetTeamsByIdSerie_TeamsForThatSerieExist_ReturnsTeamList()
        {
            var serie = SerieCommands.SaveSerie(new Serie {
                Description = RandomUtil.GetRandomString()
            }, Context);

            TeamCommands.SaveTeam(new Team {
                Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(), IdSerie = serie.IdSerie
            }, Context);
            TeamCommands.SaveTeam(new Team {
                Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(), IdSerie = serie.IdSerie
            }, Context);
            var teams = TeamQueries.GetTeamsByIdSerie(Context, serie.IdSerie);

            Assert.IsNotNull(teams);
            Assert.AreEqual(2, teams.Count);
        }
コード例 #6
0
        public override void SaveEntity_EntityExists_EntityIsUpdated()
        {
            var competition = CreateCompetition();
            var serie       = SerieCommands.SaveSerie(new Serie {
                Description = RandomUtil.GetRandomString(), IdCompetition = competition.IdCompetition
            }, Context);

            Assert.IsNotNull(serie);

            var teamsToPromote = RandomUtil.GetRandomNumber(1);

            serie.TeamsPromote = teamsToPromote;
            serie.SaveSerie(Context);

            var serieDb = SerieQueries.GetSerieById(Context, serie.IdSerie);

            Assert.IsNotNull(serieDb.TeamsPromote);
            Assert.AreEqual(teamsToPromote, serieDb.TeamsPromote);
        }
コード例 #7
0
        public void GetSeriesByIdCompetition_SeriesForThatIdExist_ReturnsAllSeries()
        {
            var competition = CompetitionCommands.SaveCompetition(
                new Competition {
                Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(150)
            },
                Context);

            SerieCommands.SaveSerie(new Serie {
                Description = RandomUtil.GetRandomString(), IdCompetition = competition.IdCompetition
            }, Context);
            SerieCommands.SaveSerie(new Serie {
                Description = RandomUtil.GetRandomString(), IdCompetition = competition.IdCompetition
            }, Context);

            var series = SerieQueries.GetSeriesByIdCompetition(Context, competition.IdCompetition);

            Assert.IsNotNull(series);
            Assert.AreEqual(2, series.Count);
        }