Beispiel #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);
        }
 private Competition CreateCompetition()
 {
     return(CompetitionCommands.SaveCompetition(
                new Competition {
         Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(150)
     },
                Context));
 }
        public override void SaveEntity_EntityIsNew_EntityIsCreated()
        {
            Competition competition = CompetitionCommands.SaveCompetition(new Competition {
                Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(100)
            }, Context);

            Assert.IsNotNull(competition.IdCompetition);
        }
        public override void GetEntityById_EntityDoesExist_ReturnsEntity()
        {
            var competition = CompetitionCommands.SaveCompetition(new Competition {
                Name = RandomUtil.GetRandomString(), Description = RandomUtil.GetRandomString(150)
            }, Context);

            Assert.IsNotNull(CompetitionQueries.GetCompetitionById(Context, competition.IdCompetition));
        }
        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);
        }
        public void GetCompetitionByPartOfDescription_ReturnsListOfCompetitions()
        {
            var description = RandomUtil.GetRandomString(200);

            CompetitionCommands.SaveCompetition(new Competition {
                Name = RandomUtil.GetRandomString(30), Description = description
            }, Context);
            var competitions = CompetitionQueries.GetCompetitionByPartOfDescription(Context,
                                                                                    description.Substring(RandomUtil.GetRandomNumber(1), RandomUtil.GetRandomNumber(2) + 1));

            Assert.IsNotEmpty(competitions);
            Assert.IsNotNull(competitions.FirstOrDefault(c => c.Description == description));
        }
        public void GetCompetitionByPartOfName_ReturnsListOfCompetitions()
        {
            var name = RandomUtil.GetRandomString(30);

            CompetitionCommands.SaveCompetition(new Competition {
                Name = name, Description = RandomUtil.GetRandomString(150)
            }, Context);
            var competitions = CompetitionQueries.GetCompetitionByPartOfName(Context,
                                                                             name.Substring(RandomUtil.GetRandomNumber(1), RandomUtil.GetRandomNumber(1) + 1));

            Assert.IsNotEmpty(competitions);
            Assert.IsNotNull(competitions.FirstOrDefault(c => c.Name == name));
        }
        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);
        }
        public override void SaveEntity_EntityExists_EntityIsUpdated()
        {
            var name        = RandomUtil.GetRandomString();
            var description = RandomUtil.GetRandomString(100);
            var competition =
                CompetitionCommands.SaveCompetition(new Competition {
                Name = name, Description = description
            }, Context);
            var newName        = RandomUtil.GetRandomString();
            var newDescription = RandomUtil.GetRandomString(100);

            competition.Name        = newName;
            competition.Description = newDescription;
            competition.SaveCompetition(Context);

            var competitionDb = CompetitionQueries.GetCompetitionById(Context, competition.IdCompetition);

            Assert.IsNotNull(competitionDb);
            Assert.AreNotEqual(name, competitionDb.Name);
            Assert.AreNotEqual(description, competitionDb.Description);
            Assert.AreEqual(newName, competitionDb.Name);
            Assert.AreEqual(newDescription, competitionDb.Description);
        }