예제 #1
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);
        }
예제 #2
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");
        }