public async Task GetFollowsByUserIdAsync_Should_Pass() { // Arrange FollowerDto followerDto1 = new FollowerDto { UserId = 1, FollowerUserId = 2 }; FollowerDto followerDto2 = new FollowerDto { UserId = 3, FollowerUserId = 2 }; FollowerDto followerDto3 = new FollowerDto { UserId = 4, FollowerUserId = 2 }; await FollowerService.FollowUserAsync(followerDto1); await FollowerService.FollowUserAsync(followerDto2); await FollowerService.FollowUserAsync(followerDto3); // Act List <Follower> follows = (await FollowerRepository.FindManyByExpressionAsync(follower => follower.FollowerUserId.Equals(2))).ToList(); // Assert Assert.IsTrue(follows.All(follower => follower.UserId.Equals(1) || follower.UserId.Equals(3) || follower.UserId.Equals(4))); }
public async Task Initialize() { ApplicationDbFactory = new ApplicationDbFactory("InMemoryDatabase"); await ApplicationDbFactory.Create().Database.EnsureDeletedAsync(); await ApplicationDbFactory.Create().Database.EnsureCreatedAsync(); ApplicationDbFactory.Create().ResetValueGenerators(); ApplicationUserRepository = new UserRepository(ApplicationDbFactory.Create(), ApplicationUserValidator); FollowerRepository = new FollowerRepository(ApplicationDbFactory.Create(), FollowerValidator); CredentialRepository = new CredentialRepository(ApplicationDbFactory.Create(), CredentialValidator); CredentialTypeRepository = new CredentialTypeRepository(ApplicationDbFactory.Create(), CredentialTypeValidator); RoleRepository = new RoleRepository(ApplicationDbFactory.Create(), RoleValidator); UserRoleRepository = new UserRoleRepository(ApplicationDbFactory.Create(), UserRoleValidator); RolePermissionRepository = new RolePermissionRepository(ApplicationDbFactory.Create(), RolePermissionValidator); PermissionRepository = new PermissionRepository(ApplicationDbFactory.Create(), PermissionValidator); HttpContextAccessor = new HttpContextAccessor(); // NOTE: Don't actually use it, when using Startup it will inject the HttpContext. (here it will always be null) UserManager = new UserManager(ApplicationUserRepository, CredentialTypeRepository, CredentialRepository, RoleRepository, UserRoleRepository, RolePermissionRepository, PermissionRepository, HttpContextAccessor, Hasher, SaltGenerator); UserService = new UserService(UserManager, ApplicationUserRepository, FollowerRepository); // A Credential type is required for a user to be able to login or register. await CredentialTypeRepository.CreateAsync(new CredentialType { Code = "Email", Name = "Email", Position = 1 }); }
public async Task InitializeAsync() { ApplicationDbFactory = new ApplicationDbFactory("InMemoryDatabase"); await ApplicationDbFactory.Create().Database.EnsureDeletedAsync(); await ApplicationDbFactory.Create().Database.EnsureCreatedAsync(); ApplicationDbFactory.Create().ResetValueGenerators(); ApplicationUserRepository = new UserRepository(ApplicationDbFactory.Create(), ApplicationUserValidator); FollowerRepository = new FollowerRepository(ApplicationDbFactory.Create(), FollowerValidator); CredentialRepository = new CredentialRepository(ApplicationDbFactory.Create(), CredentialValidator); CredentialTypeRepository = new CredentialTypeRepository(ApplicationDbFactory.Create(), CredentialTypeValidator); RoleRepository = new RoleRepository(ApplicationDbFactory.Create(), RoleValidator); UserRoleRepository = new UserRoleRepository(ApplicationDbFactory.Create(), UserRoleValidator); RolePermissionRepository = new RolePermissionRepository(ApplicationDbFactory.Create(), RolePermissionValidator); PermissionRepository = new PermissionRepository(ApplicationDbFactory.Create(), PermissionValidator); HttpContextAccessor = new HttpContextAccessor(); // NOTE: Don't actually use it, when using Startup it will inject the HttpContext. (here it will always be null) UserManager = new UserManager(ApplicationUserRepository, CredentialTypeRepository, CredentialRepository, RoleRepository, UserRoleRepository, RolePermissionRepository, PermissionRepository, HttpContextAccessor, Hasher, SaltGenerator); UserService = new UserService(UserManager, ApplicationUserRepository, FollowerRepository); FollowerService = new FollowerService(FollowerRepository, ApplicationUserRepository); // A Credential type is required for a user to be able to login or register. await CredentialTypeRepository.CreateAsync(new CredentialType { Code = "Email", Name = "Email", Position = 1 }); await UserService.SignUpAsync(new RegisterUserDto { Email = "*****@*****.**", Password = "******", UserName = "******" }); await UserService.SignUpAsync(new RegisterUserDto { Email = "*****@*****.**", Password = "******", UserName = "******" }); await UserService.SignUpAsync(new RegisterUserDto { Email = "*****@*****.**", Password = "******", UserName = "******" }); await UserService.SignUpAsync(new RegisterUserDto { Email = "*****@*****.**", Password = "******", UserName = "******" }); }
public UnitOfWork(ApplicationDbContext context) { _context = context; Attendances = new AttendanceRepository(context); Gigs = new GigsRepository(context); Followers = new FollowerRepository(context); Genres = new GenreRepository(context); }
public UnitOfWork(EventifyDbContext context) { _context = context; Users = new UserRepository(_context); Events = new EventRepository(_context); Categories = new CategoryRepository(_context); Attendances = new AttendanceRepository(context); Followers = new FollowerRepository(context); Photos = new PhotoRepository(context); }
public async Task Initialize() { ApplicationDbFactory = new ApplicationDbFactory("InMemoryDatabase"); await ApplicationDbFactory.Create().Database.EnsureDeletedAsync(); await ApplicationDbFactory.Create().Database.EnsureCreatedAsync(); ApplicationDbFactory.Create().ResetValueGenerators(); MemeRepository = new MemeRepository(ApplicationDbFactory.Create(), MemeValidator); ApplicationUserRepository = new UserRepository(ApplicationDbFactory.Create(), ApplicationUserValidator); FollowerRepository = new FollowerRepository(ApplicationDbFactory.Create(), FollowerValidator); CredentialRepository = new CredentialRepository(ApplicationDbFactory.Create(), CredentialValidator); CredentialTypeRepository = new CredentialTypeRepository(ApplicationDbFactory.Create(), CredentialTypeValidator); RoleRepository = new RoleRepository(ApplicationDbFactory.Create(), RoleValidator); UserRoleRepository = new UserRoleRepository(ApplicationDbFactory.Create(), UserRoleValidator); RolePermissionRepository = new RolePermissionRepository(ApplicationDbFactory.Create(), RolePermissionValidator); PermissionRepository = new PermissionRepository(ApplicationDbFactory.Create(), PermissionValidator); CommentRepository = new CommentRepository(ApplicationDbFactory.Create(), CommentValidator); HttpContextAccessor = new HttpContextAccessor(); // NOTE: Don't actually use it, when using Startup it will inject the HttpContext. (here it will always be null) UserManager = new UserManager(ApplicationUserRepository, CredentialTypeRepository, CredentialRepository, RoleRepository, UserRoleRepository, RolePermissionRepository, PermissionRepository, HttpContextAccessor, Hasher, SaltGenerator); UserService = new UserService(UserManager, ApplicationUserRepository, FollowerRepository); CommentService = new CommentService(CommentRepository, MemeRepository); // A Credential type is required for a user to be able to login or register. await CredentialTypeRepository.CreateAsync(new CredentialType { Code = "Email", Name = "Email", Position = 1 }); await UserService.SignUpAsync(new RegisterUserDto { Email = "*****@*****.**", Password = "******", UserName = "******" }); Meme meme = new Meme { Id = "a0Q558q", ImageUrl = "https://images-cdn.9gag.com/photo/a0Q558q_700b.jpg", VideoUrl = "http://img-9gag-fun.9cache.com/photo/a0Q558q_460sv.mp4", PageUrl = "http://9gag.com/gag/a0Q558q", Title = "Old but Gold" }; await MemeRepository.CreateAsync(meme); }
public async Task GetMutualFollowersByUserIdAsync_Should_Pass() { // Arrange FollowerDto followerDto1 = new FollowerDto { UserId = 1, FollowerUserId = 2 }; FollowerDto followerDto2 = new FollowerDto { UserId = 2, FollowerUserId = 1 }; FollowerDto followerDto3 = new FollowerDto { UserId = 4, FollowerUserId = 1 }; FollowerDto followerDto4 = new FollowerDto { UserId = 1, FollowerUserId = 4 }; await FollowerService.FollowUserAsync(followerDto1); await FollowerService.FollowUserAsync(followerDto2); await FollowerService.FollowUserAsync(followerDto3); await FollowerService.FollowUserAsync(followerDto4); // Act List <Follower> follows = (await FollowerRepository.FindManyByExpressionAsync(follower => follower.FollowerUserId.Equals(1))).ToList(); List <Follower> followers = (await FollowerRepository.FindManyByExpressionAsync(follower => follower.UserId.Equals(1))).ToList(); List <bool> mutualFollows = followers.Select(follower => follows.Any(following => following.UserId.Equals(follower.FollowerUserId))).ToList(); // Assert Assert.AreEqual(mutualFollows.Count, 2); }
public FollowerController(FollowerRepository repository) { _repository = repository; }
public FollowerService(FollowerRepository followerDb) { _followerDb = followerDb; }
public async Task InitializeAsync() { ApplicationDbFactory = new ApplicationDbFactory("InMemoryDatabase"); await ApplicationDbFactory.Create().Database.EnsureDeletedAsync(); await ApplicationDbFactory.Create().Database.EnsureCreatedAsync(); ApplicationDbFactory.Create().ResetValueGenerators(); MemeRepository = new MemeRepository(ApplicationDbFactory.Create(), MemeValidator); SharedMemeRepository = new SharedMemeRepository(ApplicationDbFactory.Create(), SharedMemeValidator); ApplicationUserRepository = new UserRepository(ApplicationDbFactory.Create(), ApplicationUserValidator); FollowerRepository = new FollowerRepository(ApplicationDbFactory.Create(), FollowerValidator); CredentialRepository = new CredentialRepository(ApplicationDbFactory.Create(), CredentialValidator); CredentialTypeRepository = new CredentialTypeRepository(ApplicationDbFactory.Create(), CredentialTypeValidator); RoleRepository = new RoleRepository(ApplicationDbFactory.Create(), RoleValidator); UserRoleRepository = new UserRoleRepository(ApplicationDbFactory.Create(), UserRoleValidator); RolePermissionRepository = new RolePermissionRepository(ApplicationDbFactory.Create(), RolePermissionValidator); PermissionRepository = new PermissionRepository(ApplicationDbFactory.Create(), PermissionValidator); CommentRepository = new CommentRepository(ApplicationDbFactory.Create(), CommentValidator); HttpContextAccessor = new HttpContextAccessor(); // NOTE: Don't actually use it, when using Startup it will inject the HttpContext. (here it will always be null) UserManager = new UserManager(ApplicationUserRepository, CredentialTypeRepository, CredentialRepository, RoleRepository, UserRoleRepository, RolePermissionRepository, PermissionRepository, HttpContextAccessor, Hasher, SaltGenerator); UserService = new UserService(UserManager, ApplicationUserRepository, FollowerRepository); FollowerService = new FollowerService(FollowerRepository, ApplicationUserRepository); MemeSharingService = new MemeSharingService(SharedMemeRepository, ApplicationUserRepository); // NOTE: A CredentialType is required for a user to be able to login or register. await CredentialTypeRepository.CreateAsync(new CredentialType { Code = "Email", Name = "Email", Position = 1 }); await UserService.SignUpAsync(new RegisterUserDto { Email = "*****@*****.**", Password = "******", UserName = "******" }); await UserService.SignUpAsync(new RegisterUserDto { Email = "*****@*****.**", Password = "******", UserName = "******" }); FollowerDto followerDto1 = new FollowerDto { UserId = 1, FollowerUserId = 2 }; FollowerDto followerDto2 = new FollowerDto { UserId = 2, FollowerUserId = 1 }; await FollowerService.FollowUserAsync(followerDto1); await FollowerService.FollowUserAsync(followerDto2); Meme meme1 = new Meme { Id = "a0Q558q", ImageUrl = "https://images-cdn.9gag.com/photo/a0Q558q_700b.jpg", VideoUrl = "http://img-9gag-fun.9cache.com/photo/a0Q558q_460sv.mp4", PageUrl = "http://9gag.com/gag/a0Q558q", Title = "Old but Gold" }; await MemeRepository.CreateAsync(meme1); Meme meme2 = new Meme { Id = "a0QQZoL", ImageUrl = "https://images-cdn.9gag.com/photo/a0QQZoL_700b.jpg", VideoUrl = "http://img-9gag-fun.9cache.com/photo/a0QQZoL_460sv.mp4", PageUrl = "http://9gag.com/gag/a0QQZoL", Title = "Austin was listed for a heart transplant, and the doctor said he would deliver the news a heart was available dressed as Chewbacca." }; await MemeRepository.CreateAsync(meme2); }
public IEnumerator <Follower> DeserializeRangeGet(string value) { var repository = new FollowerRepository(new TictailClientTest(), "abc"); return(repository.DeserializeRangeGet(value)); }
public FollowerController(DataContext context, FollowerRepository repository) { _context = context; _repository = repository; }