Ejemplo n.º 1
0
        public void CreateInvalidNullSportTest()
        {
            SportServices service = new SportServices(login, sportRepo);
            SportDTO      sport   = new SportDTO();

            service.CreateSport(sport);
        }
Ejemplo n.º 2
0
        public void RecoverAllFollowedTeams()
        {
            ILoginServices loginServices = new LoginServices(userRepo, teamRepo);
            IUserServices  userServices  = new UserServices(loginServices, userRepo, teamRepo, sportRepo);
            ITeamServices  teamServices  = new TeamServices(loginServices, teamRepo, sportRepo, userRepo);
            ISportServices sportServices = new SportServices(loginServices, sportRepo);

            loginServices.CreateSession("sSanchez", "user");

            TeamDTO cavaliers = new TeamDTO()
            {
                Name      = "Cavaliers",
                Logo      = EncondeImage(Image.FromFile(GetResourcePath("Cavaliers.jpg"))),
                SportName = "Baskteball"
            };
            SportDTO basketball = new SportDTO()
            {
                Name = "Baskteball"
            };

            TeamDTO team = new TeamDTO()
            {
                Name      = "Cavaliers",
                Logo      = EncondeImage(Image.FromFile(GetResourcePath("Cavaliers.jpg"))),
                SportName = "Baskteball"
            };

            sportServices.CreateSport(basketball);
            teamServices.CreateTeam(team);
            teamServices.AddFollowedTeam("Cavaliers_Baskteball");

            IEnumerable <TeamDTO> followedTeams = userServices.GetFollowedTeams();

            Assert.AreEqual(cavaliers.Name, followedTeams.First().Name);
        }
Ejemplo n.º 3
0
        public void CreatedSportTest()
        {
            SportServices service = new SportServices(login, sportRepo);

            service.CreateSport(rugby);

            Assert.IsTrue(sportRepo.GetAll().Any(s => s.Name.Equals(rugby.Name)));
        }
Ejemplo n.º 4
0
        public void FollowTeam()
        {
            ILoginServices loginServices = new LoginServicesMock(pepe);
            ITeamServices  teamServices  = new TeamServices(loginServices, teamRepo, sportRepo, userRepo);
            ISportServices sportServices = new SportServices(loginServices, sportRepo);

            SportDTO basketball = new SportDTO()
            {
                Name = "Basketball"
            };

            sportServices.CreateSport(basketball);

            TeamDTO cavaliers = new TeamDTO()
            {
                Name      = "Cavaliers",
                Logo      = EncondeImage(Image.FromFile(GetResourcePath("Cavaliers.jpg"))),
                SportName = "Basketball"
            };

            teamServices.CreateTeam(cavaliers);
            userRepo.Add(new User()
            {
                UserName = pepe.UserName,
                Name     = pepe.Name,
                Surname  = pepe.Surname,
                Mail     = pepe.Mail,
                Password = pepe.Password,
                Role     = pepe.IsAdmin ? Role.Administrator : Role.Follower
            });
            userRepo.Add(new User()
            {
                UserName = pablo.UserName,
                Name     = pablo.Name,
                Surname  = pablo.Surname,
                Mail     = pablo.Mail,
                Password = pablo.Password,
                Role     = pablo.IsAdmin ? Role.Administrator : Role.Follower
            });
            loginServices = new LoginServicesMock(pablo);
            teamServices.AddFollowedTeam("Cavaliers_Basketball");

            User        recovered     = userRepo.Get(pepe.UserName);
            List <Team> followedTeams = recovered.FollowedTeams.ToList();

            Assert.IsTrue(followedTeams.First().Name == "Cavaliers");
        }
Ejemplo n.º 5
0
        public void CreateAlreadyExistingSport()
        {
            SportServices service = new SportServices(login, sportRepo);

            service.CreateSport(futbol);
        }