public async Task CreateFriendshipAsync_CreateFriendship_FriendshipCreated(int userId1, int userId2) { Mock <IDataGateway> dataGateway = new Mock <IDataGateway>(); Mock <IConnectionStringData> connectionString = new Mock <IConnectionStringData>(); Mock <IFriendRequestListRepo> friendRequestListRepo = new Mock <IFriendRequestListRepo>( ); Mock <IFriendBlockListRepo> friendBlockListRepo = new Mock <IFriendBlockListRepo>( ); Mock <IFriendListRepo> friendListRepo = new Mock <IFriendListRepo>( ); Mock <IUserReportsRepo> userReportsRepo = new Mock <IUserReportsRepo>( ); Mock <IUserAccountRepository> userAccountRepository = new Mock <IUserAccountRepository>( ); Mock <IUserAccountService> userAccountService = new Mock <IUserAccountService>(); Mock <IValidationService> validationService = new Mock <IValidationService>(); IUserInteractionService userInteractionService = new UserInteractionService(friendBlockListRepo.Object, friendListRepo.Object, friendRequestListRepo.Object, userReportsRepo.Object, validationService.Object); try { await userInteractionService.CreateFriendshipAsync(userId1, userId2); } catch { Assert.IsTrue(false); } }
public async Task GetAllUserFriends_CreatRequest_RequestCreated(int userId1, int userId2) { Mock <IDataGateway> dataGateway = new Mock <IDataGateway>(); Mock <IConnectionStringData> connectionString = new Mock <IConnectionStringData>(); Mock <IFriendRequestListRepo> friendRequestListRepo = new Mock <IFriendRequestListRepo>( ); Mock <IFriendBlockListRepo> friendBlockListRepo = new Mock <IFriendBlockListRepo>( ); Mock <IFriendListRepo> friendListRepo = new Mock <IFriendListRepo>( ); Mock <IUserReportsRepo> userReportsRepo = new Mock <IUserReportsRepo>( ); Mock <IUserAccountRepository> userAccountRepository = new Mock <IUserAccountRepository>( ); Mock <IUserProfileRepository> userProfileRepository = new Mock <IUserProfileRepository>( ); Mock <IUserProfileService> userProfileService = new Mock <IUserProfileService>(); Mock <IUserAccountService> userAccountService = new Mock <IUserAccountService>(); Mock <IValidationService> validationService = new Mock <IValidationService>(); IUserInteractionService userInteractionService = new UserInteractionService(friendBlockListRepo.Object, friendListRepo.Object, friendRequestListRepo.Object, userReportsRepo.Object, validationService.Object); try { await userInteractionService.CreateFriendshipAsync(userId1, userId2); IEnumerable <FriendsListJunctionModel> friendsListJunctionModels = await userInteractionService.GetAllUserFriends(userId2); } catch { Assert.IsTrue(false); } }
public async Task GetAllUserFriends_CreatRequest_RequestCreated(int userId1, int userId2) { IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IFriendRequestListRepo friendRequestListRepo = new FriendRequestListRepo(dataGateway, connectionString); IFriendBlockListRepo friendBlockListRepo = new FriendBlockListRepo(dataGateway, connectionString); IFriendListRepo friendListRepo = new FriendListRepo(dataGateway, connectionString); IUserReportsRepo userReportsRepo = new UserReportsRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IUserProfileRepository userProfileRepository = new UserProfileRepository(dataGateway, connectionString); IUserProfileService userProfileService = new UserProfileService(userProfileRepository); IUserAccountService userAccountService = new UserAccountService(userAccountRepository); IValidationService validationService = new ValidationService(userAccountService, userProfileService); IUserInteractionService userInteractionService = new UserInteractionService(friendBlockListRepo, friendListRepo, friendRequestListRepo, userReportsRepo, validationService); try { await userInteractionService.CreateFriendshipAsync(userId1, userId2); IEnumerable <FriendsListJunctionModel> friendsListJunctionModels = await userInteractionService.GetAllUserFriends(userId2); if (friendsListJunctionModels == null) { Assert.IsTrue(false); } if (friendsListJunctionModels.Count() == 0) { Assert.IsTrue(false); } foreach (var friendsListJunctionModel in friendsListJunctionModels) { if (friendsListJunctionModel.User1Id == userId1 && friendsListJunctionModel.User2Id == userId2) { Assert.IsTrue(true); } } } catch { Assert.IsTrue(false); } }
public async Task TrackFriendNumber_ReturnAvgFriends() { //arrange IDataGateway dataGateway = new SQLServerGateway(); IConnectionStringData connectionString = new ConnectionStringData(); IFriendListRepo friendListRepo = new FriendListRepo(dataGateway, connectionString); IFriendRequestListRepo friendRequestListRepo = new FriendRequestListRepo(dataGateway, connectionString); IUserAccountRepository userAccountRepository = new UserAccountRepository(dataGateway, connectionString); IFriendBlockListRepo friendBlockListRepo = new FriendBlockListRepo(dataGateway, connectionString); IPublicUserProfileRepo publicUserProfileRepo = new PublicUserProfileRepo(dataGateway, connectionString); IListingRepository listingRepository = new ListingRepository(dataGateway, connectionString); ILoginTrackerRepo loginTrackerRepo = new LoginTrackerRepo(dataGateway, connectionString); IPageVisitTrackerRepo pageVisitTrackerRepo = new PageVisitTrackerRepo(dataGateway, connectionString); ISearchTrackerRepo searchTrackerRepo = new SearchTrackerRepo(dataGateway, connectionString); IUserAnalysisService userAnalysisService = new UserAnalysisService(friendListRepo, listingRepository, userAccountRepository, loginTrackerRepo, pageVisitTrackerRepo, friendRequestListRepo, searchTrackerRepo); IUserReportsRepo userReportsRepo = new UserReportsRepo(dataGateway, connectionString); IUserProfileRepository userProfileRepository = new UserProfileRepository(dataGateway, connectionString); IUserProfileService userProfileService = new UserProfileService(userProfileRepository); IUserAccountService userAccountService = new UserAccountService(userAccountRepository); IValidationService validationService = new ValidationService(userAccountService, userProfileService); IUserInteractionService userInteractionService = new UserInteractionService(friendBlockListRepo, friendListRepo, friendRequestListRepo, userReportsRepo, validationService); await userInteractionService.CreateFriendshipAsync(1, 2); try { int avarageFriends = await userAnalysisService.GetAvgFriends(); if (avarageFriends != 1) { Assert.IsTrue(false); } Assert.IsTrue(true); } catch { Assert.IsTrue(false); } }