public void AddRegisteredUser_Added_NotFail_Test() { IRegisteredUserRepository target = new RegisteredUserRepository(); RegisteredUser registeredUser = new RegisteredUser(); registeredUser.Name = Guid.NewGuid().ToString(); registeredUser.FacebookId = Guid.NewGuid().ToString(); registeredUser.Email = Guid.NewGuid().ToString(); Assert.IsTrue(target.Add(registeredUser) > 0); }
public void GetIfUserIsRegistered_NotRegistered_Test() { int eventDefinitionId = 10; int registeredUserId = 10000; IRegisteredUserRepository target = new RegisteredUserRepository(); bool actual = target.GetIfUserIsRegistered(eventDefinitionId, registeredUserId); Assert.IsFalse(actual); }
public void AddRegisteredUser_Added_NotFail_Test() { IRegisteredUserRepository target = new RegisteredUserRepository(); RegisteredUser registeredUser = new RegisteredUser(); registeredUser.Name = Guid.NewGuid().ToString(); registeredUser.FacebookId = Guid.NewGuid().ToString(); registeredUser.Email = Guid.NewGuid().ToString(); Assert.IsTrue(target.Add(registeredUser) > 0); }
public void GetRegisteredUser_Call_GetResults_Test() { var context = new MyEventsContext(); string registeredFacebookId = context.RegisteredUsers.FirstOrDefault().FacebookId; IRegisteredUserRepository target = new RegisteredUserRepository(); RegisteredUser registeredUser = target.Get(registeredFacebookId); Assert.IsNotNull(registeredUser); Assert.AreEqual(registeredFacebookId, registeredUser.FacebookId); }
public void GetRegisteredUserById_Call_GetResults_Test() { var context = new MyEventsContext(); int registeredUserId = context.RegisteredUsers.FirstOrDefault().RegisteredUserId; IRegisteredUserRepository target = new RegisteredUserRepository(); RegisteredUser registeredUser = target.GetById(registeredUserId); Assert.IsNotNull(registeredUser); Assert.AreEqual(registeredUserId, registeredUser.RegisteredUserId); }
public void AddRegisteredUser_NotAdded_AlreadyExists_Test() { var context = new MyEventsContext(); var user = context.RegisteredUsers.FirstOrDefault(); IRegisteredUserRepository target = new RegisteredUserRepository(); RegisteredUser registeredUser = new RegisteredUser(); registeredUser.Name = Guid.NewGuid().ToString(); registeredUser.FacebookId = user.FacebookId; registeredUser.Email = Guid.NewGuid().ToString(); int actual = target.Add(registeredUser); Assert.AreEqual(user.RegisteredUserId, actual ); }
public void GetEventDefinitions_Call_GetResults_NotFail_Test() { var context = new MyEventsContext(); int registerUserId = context.RegisteredUsers.FirstOrDefault().RegisteredUserId; IRegisteredUserRepository target = new RegisteredUserRepository(); IEnumerable <EventDefinition> results = target.GetEventDefinitions(registerUserId); Assert.IsNotNull(results); }
public static void LoadFromDatabase(string userName) { int providerUserKey = 0; MembershipUser mu; // Given we are saving on Session if the Session expires we need to retrieve again from DB. if (userName != null) { mu = Membership.GetUser(userName); } else { mu = Membership.GetUser(); } if (mu != null) { providerUserKey = Convert.ToInt32(mu.ProviderUserKey); } else { HttpContext.Current.Response.Redirect("/"); } // Create the Registered User repository RegisteredUserRepository rup = new RegisteredUserRepository(); RegisteredUser ru = rup.GetByMembershipId(providerUserKey); if (ru != null) { UserData ud = new UserData(); ud.UserId = ru.Id; ud.ClosetId = ru.Closet.Id; ud.Channel = ru.Channel; string[] flavors = new string[ru.UserFlavors.Count]; for (int i = 0; i < ru.UserFlavors.Count; i++) { flavors[i] = ru.UserFlavors[i].Flavor.Id.ToString(); } ud.Flavors = string.Join(",", flavors); string[] flavornames = new string[ru.UserFlavors.Count]; for (int i = 0; i < ru.UserFlavors.Count; i++) { flavornames[i] = ru.UserFlavors[i].Flavor.Name; } ud.FlavorNames = string.Join(",", flavornames); HttpContext.Current.Session[USERDATA] = ud; } }
private RegisteredUser GetUser() { RegisteredUserRepository rur = new RegisteredUserRepository(); MembershipUser mu = Membership.GetUser(); if (mu != null) { ViewData["UserName"] = mu.UserName; } return(rur.GetByMembershipId(Convert.ToInt32(mu.ProviderUserKey))); }
public void AddRegisteredUser_NotAdded_AlreadyExists_Test() { var context = new MyEventsContext(); var user = context.RegisteredUsers.FirstOrDefault(); IRegisteredUserRepository target = new RegisteredUserRepository(); RegisteredUser registeredUser = new RegisteredUser(); registeredUser.Name = Guid.NewGuid().ToString(); registeredUser.FacebookId = user.FacebookId; registeredUser.Email = Guid.NewGuid().ToString(); int actual = target.Add(registeredUser); Assert.AreEqual(user.RegisteredUserId, actual); }
public void GetAllBySessionId_Call_NotFail_Test() { var context = new MyEventsContext(); int sessionId = context.Sessions.FirstOrDefault().SessionId; int expectedCount = context.SessionRegisteredUsers .Where(q => q.SessionId == sessionId).Count(); IRegisteredUserRepository target = new RegisteredUserRepository(); IEnumerable <RegisteredUser> results = target.GetAllBySessionId(sessionId); Assert.IsNotNull(results); Assert.AreEqual(expectedCount, results.Count()); }
public void AddRegisteredUserToSession_Added_NotFail_Test() { var context = new MyEventsContext(); int eventDefinitionId = context.RegisteredUsers.FirstOrDefault().RegisteredUserId; int sessionId = context.Sessions.FirstOrDefault().SessionId; int expected = context.SessionRegisteredUsers.Count() + 1; IRegisteredUserRepository target = new RegisteredUserRepository(); target.AddRegisteredUserToSession(eventDefinitionId, sessionId); int actual = context.SessionRegisteredUsers.Count(); Assert.AreEqual(expected, actual); }
public void DeleteRegisteredUserFromSession_Deleted_NotFail_Test() { var context = new MyEventsContext(); SessionRegisteredUser sessionRegisteredUser = context.SessionRegisteredUsers.FirstOrDefault(); int expected = context.SessionRegisteredUsers.Count() - 1; IRegisteredUserRepository target = new RegisteredUserRepository(); target.DeleteRegisteredUserFromSession(sessionRegisteredUser.RegisteredUserId, sessionRegisteredUser.SessionId); int actual = context.SessionRegisteredUsers.Count(); Assert.AreEqual(expected, actual); }
public void AddRegisteredUserToSession_Added_NotFail_Test() { var context = new MyEventsContext(); int eventDefinitionId = context.RegisteredUsers.FirstOrDefault().RegisteredUserId; int sessionId = context.Sessions.FirstOrDefault().SessionId; int expected = context.SessionRegisteredUsers.Count() + 1; IRegisteredUserRepository target = new RegisteredUserRepository(); target.AddRegisteredUserToSession(eventDefinitionId, sessionId); int actual = context.SessionRegisteredUsers.Count(); Assert.AreEqual(expected, actual); }
public void GetSessions_Call_GetResults_NotFail_Test() { var context = new MyEventsContext(); var session = context.Sessions .Include("SessionRegisteredUsers") .Where(q => q.SessionRegisteredUsers.Any()) .FirstOrDefault(); int sessionId = session.EventDefinitionId; int registeredUserId = session.SessionRegisteredUsers.First().RegisteredUserId; IRegisteredUserRepository target = new RegisteredUserRepository(); IEnumerable <Session> results = target.GetSessions(session.EventDefinitionId, registeredUserId); Assert.IsNotNull(results); }
public void GetAllByEventId_Call_NotFail_Test() { var context = new MyEventsContext(); int eventDefinitionId = context.RegisteredUsers.Include("AttendeeEventDefinitions") .FirstOrDefault(q => q.AttendeeEventDefinitions.Any()).AttendeeEventDefinitions.First().EventDefinitionId; int expectedCount = context.RegisteredUsers.Include("AttendeeEventDefinitions") .Count(q => q.AttendeeEventDefinitions.Any(s => s.EventDefinitionId == eventDefinitionId)); IRegisteredUserRepository target = new RegisteredUserRepository(); IEnumerable <RegisteredUser> results = target.GetAllByEventId(eventDefinitionId); Assert.IsNotNull(results); Assert.AreEqual(expectedCount, results.Count()); }
public void GetIfUserIsRegistered_Test() { int eventDefinitionId = 0; int registeredUserId = 0; using (var context = new MyEventsContext()) { var registeredUser = context.RegisteredUsers.Include("AttendeeEventDefinitions").FirstOrDefault(a => a.AttendeeEventDefinitions.Any()); eventDefinitionId = registeredUser.AttendeeEventDefinitions.FirstOrDefault().EventDefinitionId; registeredUserId = registeredUser.RegisteredUserId; } IRegisteredUserRepository target = new RegisteredUserRepository(); bool actual = target.GetIfUserIsRegistered(eventDefinitionId, registeredUserId); Assert.IsTrue(actual); }
public RedirectToRouteResult Details(int id, [Bind(Prefix = "User.Email")] string email, [Bind(Prefix = "User.Comment")] string comment) { var user = _userService.Get(id); user.Email = email; user.Comment = comment; _userService.Update(user); //Update email also in our Registered User Table RegisteredUserRepository rur = new RegisteredUserRepository(); rur.UpdateEmail(rur.GetByMembershipId(id), email); return(RedirectToAction("Details", new { id })); }
public void AddRegisteredUserToEvent_Added_NotFail_Test() { var context = new MyEventsContext(); int registeredUserId = context.RegisteredUsers.First().RegisteredUserId; var eventDefinition = context.EventDefinitions.Include("RegisteredUsers") .Where(e => !e.RegisteredUsers.Any(r => r.RegisteredUserId == registeredUserId)).First(); int eventDefinitionId = eventDefinition.EventDefinitionId; int expected = eventDefinition.RegisteredUsers.Count() + 1; IRegisteredUserRepository target = new RegisteredUserRepository(); target.AddRegisteredUserToEvent(registeredUserId, eventDefinitionId); var contextAfter = new MyEventsContext(); var eventDefinitionAfter = contextAfter.EventDefinitions.Include("RegisteredUsers").First(e => e.EventDefinitionId == eventDefinitionId); int actual = eventDefinitionAfter.RegisteredUsers.Count(); Assert.AreEqual(expected, actual); }
public void AddRegisteredUserToEvent_Added_NotFail_Test() { var context = new MyEventsContext(); int registeredUserId = context.RegisteredUsers.First().RegisteredUserId; var eventDefinition = context.EventDefinitions.Include("RegisteredUsers") .Where(e => !e.RegisteredUsers.Any(r => r.RegisteredUserId == registeredUserId)).First(); int eventDefinitionId = eventDefinition.EventDefinitionId; int expected = eventDefinition.RegisteredUsers.Count() + 1; IRegisteredUserRepository target = new RegisteredUserRepository(); target.AddRegisteredUserToEvent(registeredUserId, eventDefinitionId); var contextAfter = new MyEventsContext(); var eventDefinitionAfter = contextAfter.EventDefinitions.Include("RegisteredUsers").First(e => e.EventDefinitionId == eventDefinitionId); int actual = eventDefinitionAfter.RegisteredUsers.Count(); Assert.AreEqual(expected, actual); }
public UnitOfWork(SisanjeHrDbContext context) { _context = context; Admins = new AdminRepository(_context); Owners = new OwnerRepository(_context); Subscriptions = new SubscriptionRepository(_context); Countries = new CountryRepository(_context); Cities = new CityRepository(_context); Locations = new LocationRepository(_context); RegisteredUsers = new RegisteredUserRepository(_context); Workers = new WorkerRepository(_context); HairSalons = new HairSalonRepository(_context); HairSalonMethodsOfPayment = new HairSalonMethodsOfPaymentRepository(_context); MethodsOfPayment = new MethodOfPaymentRepository(_context); HairSalonWorkingHours = new HairSalonWorkingHoursRepository(_context); WorkingHours = new WorkingHourRepository(_context); HairSalonServices = new HairSalonServicesRepository(_context); Services = new ServiceRepository(_context); Appointments = new AppointmentRepository(_context); AppointmentServices = new AppointmentServicesRepository(_context); Reviews = new ReviewRepository(_context); FavoriteHairSalons = new FavoriteHairSalonRepository(_context); }
public void GetAllBySessionId_Call_NotFail_Test() { var context = new MyEventsContext(); int sessionId = context.Sessions.FirstOrDefault().SessionId; int expectedCount = context.SessionRegisteredUsers .Where(q => q.SessionId == sessionId).Count(); IRegisteredUserRepository target = new RegisteredUserRepository(); IEnumerable<RegisteredUser> results = target.GetAllBySessionId(sessionId); Assert.IsNotNull(results); Assert.AreEqual(expectedCount, results.Count()); }
public void OneTimeSetup() { var DB = new SocialEngineDbFactory(); sut = new RegisteredUserRepository(DB); }
public void DeleteRegisteredUserFromSession_Deleted_NotFail_Test() { var context = new MyEventsContext(); SessionRegisteredUser sessionRegisteredUser = context.SessionRegisteredUsers.FirstOrDefault(); int expected = context.SessionRegisteredUsers.Count() - 1; IRegisteredUserRepository target = new RegisteredUserRepository(); target.DeleteRegisteredUserFromSession(sessionRegisteredUser.RegisteredUserId, sessionRegisteredUser.SessionId); int actual = context.SessionRegisteredUsers.Count(); Assert.AreEqual(expected, actual); }
public void GetSessions_Call_GetResults_NotFail_Test() { var context = new MyEventsContext(); var session = context.Sessions .Include("SessionRegisteredUsers") .Where(q => q.SessionRegisteredUsers.Any()) .FirstOrDefault(); int sessionId = session.EventDefinitionId; int registeredUserId = session.SessionRegisteredUsers.First().RegisteredUserId; IRegisteredUserRepository target = new RegisteredUserRepository(); IEnumerable<Session> results = target.GetSessions(session.EventDefinitionId, registeredUserId); Assert.IsNotNull(results); }
public void GetRegisteredUser_Call_GetResults_Test() { var context = new MyEventsContext(); string registeredFacebookId = context.RegisteredUsers.FirstOrDefault().FacebookId; IRegisteredUserRepository target = new RegisteredUserRepository(); RegisteredUser registeredUser = target.Get(registeredFacebookId); Assert.IsNotNull(registeredUser); Assert.AreEqual(registeredFacebookId, registeredUser.FacebookId); }
public void GetRegisteredUserById_Call_GetResults_Test() { var context = new MyEventsContext(); int registeredUserId = context.RegisteredUsers.FirstOrDefault().RegisteredUserId; IRegisteredUserRepository target = new RegisteredUserRepository(); RegisteredUser registeredUser = target.GetById(registeredUserId); Assert.IsNotNull(registeredUser); Assert.AreEqual(registeredUserId, registeredUser.RegisteredUserId); }
public void GetIfUserIsRegistered_Test() { int eventDefinitionId = 0; int registeredUserId = 0; using (var context = new MyEventsContext()) { var registeredUser = context.RegisteredUsers.Include("AttendeeEventDefinitions").FirstOrDefault(a => a.AttendeeEventDefinitions.Any()); eventDefinitionId = registeredUser.AttendeeEventDefinitions.FirstOrDefault().EventDefinitionId; registeredUserId = registeredUser.RegisteredUserId; } IRegisteredUserRepository target = new RegisteredUserRepository(); bool actual = target.GetIfUserIsRegistered(eventDefinitionId, registeredUserId); Assert.IsTrue(actual); }
public void GetIfUserIsRegistered_NotRegistered_Test() { int eventDefinitionId = 10; int registeredUserId = 10000; IRegisteredUserRepository target = new RegisteredUserRepository(); bool actual = target.GetIfUserIsRegistered(eventDefinitionId, registeredUserId); Assert.IsFalse(actual); }
public void GetEventDefinitions_Call_GetResults_NotFail_Test() { var context = new MyEventsContext(); int registerUserId = context.RegisteredUsers.FirstOrDefault().RegisteredUserId; IRegisteredUserRepository target = new RegisteredUserRepository(); IEnumerable<EventDefinition> results = target.GetEventDefinitions(registerUserId); Assert.IsNotNull(results); }
public void GetAllByEventId_Call_NotFail_Test() { var context = new MyEventsContext(); int eventDefinitionId = context.RegisteredUsers.Include("AttendeeEventDefinitions") .FirstOrDefault(q => q.AttendeeEventDefinitions.Any()).AttendeeEventDefinitions.First().EventDefinitionId; int expectedCount = context.RegisteredUsers.Include("AttendeeEventDefinitions") .Count(q => q.AttendeeEventDefinitions.Any(s => s.EventDefinitionId == eventDefinitionId)); IRegisteredUserRepository target = new RegisteredUserRepository(); IEnumerable<RegisteredUser> results = target.GetAllByEventId(eventDefinitionId); Assert.IsNotNull(results); Assert.AreEqual(expectedCount, results.Count()); }