public void FindEventsTest() { //Se inicializa en base de datos un evento con nombre: "Event name" List <DTOSportEvent> events8 = sportEventService.FindEvents("", 0, 10, "category1").result; List <DTOSportEvent> events7 = sportEventService.FindEvents(null, 0, 10).result; List <DTOSportEvent> events = sportEventService.FindEvents("name", 0, 10).result; List <DTOSportEvent> events2 = sportEventService.FindEvents("Event", 0, 10).result; List <DTOSportEvent> events3 = sportEventService.FindEvents("event", 0, 10).result; // en minuscula List <DTOSportEvent> events4 = sportEventService.FindEvents(" XXX", 0, 10).result; //Ningun evento List <DTOSportEvent> events5 = sportEventService.FindEvents("pArtiDo", 0, 10).result; // debe devolver solo 10 List <DTOSportEvent> events6 = sportEventService.FindEvents("pArtiDo", 0, 20).result; // devuelve 20 DTOSportEvent expected = events.First(); Assert.AreEqual(0, events4.Count); //Ningun evento Assert.AreEqual(1, events.Count); //Solo debe haber un elemento Assert.AreEqual(10, events5.Count); //10 eventos (maximo) Assert.AreEqual(16, events6.Count); Assert.AreEqual(0, events8.Count); Assert.AreEqual(0, events7.Count); Assert.IsTrue(expected.eventId == 1); Assert.AreEqual(events.First(), events2.First()); Assert.AreEqual(events.First(), events3.First()); Assert.IsTrue(events4.Count == 0); Assert.IsTrue(events.Count == 1); Assert.IsTrue(events5.Count == 10); }
public void ListFavoritesIncorrectUserLoginTest() { UserProfileDetails userProfileDetails = new UserProfileDetails("first name", "last name", "*****@*****.**", "es", "ES"); long userId = userService.RegisterUser("userLogin1", "password", userProfileDetails); List <DTOSportEvent> events = sportEventService.FindEvents("Event", 0, 10).result; DTOSportEvent evento = null; foreach (var ev in events) { evento = ev; } sportEventService.AddToFavorites("userLogin1", evento.eventId, "name1", "comment1"); List <DTOFavorite> favoritos = sportEventService.ListFavorites("incorrectUserLogin"); }
public void AddDuplicatedFavoriteTest() { UserProfileDetails userProfileDetails = new UserProfileDetails("first name", "last name", "*****@*****.**", "es", "ES"); long userId = userService.RegisterUser("user1", "password", userProfileDetails); List <DTOSportEvent> events = sportEventService.FindEvents("Event", 0, 10).result; DTOSportEvent evento = null; foreach (var ev in events) { evento = ev; } sportEventService.AddToFavorites("user1", evento.eventId, "name1", "comment1"); sportEventService.AddToFavorites("user1", evento.eventId, "name1", "comment1"); List <DTOFavorite> favoritos = sportEventService.ListFavorites("user1"); Assert.IsTrue(favoritos.Count == 1); UserProfile user = userProfileDao.FindByLoginName("user1"); sportEventService.DeleteFromFavorites("user1", evento.eventId); favoritos = sportEventService.ListFavorites("user1"); Assert.IsTrue(favoritos.Count == 0); List <DTOSportEvent> diezEventos = sportEventService.FindEvents("pArtiDo", 0, 10).result;// debe devolver 2 eventos foreach (var ev in diezEventos) { sportEventService.AddToFavorites("user1", ev.eventId, "name2", "comment2"); } favoritos = sportEventService.ListFavorites("user1"); int numeroEventos = 10; Assert.IsTrue(favoritos.Count == numeroEventos); foreach (var ev in diezEventos) { sportEventService.DeleteFromFavorites("user1", ev.eventId); favoritos = sportEventService.ListFavorites("user1"); numeroEventos--; Assert.IsTrue(favoritos.Count == numeroEventos); } }