public async Task GetAllUsersRegisteredToday_Countaccounts() { 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); int count = await userAnalysisService.GetAllUsersRegisteredToday(); if (count != 20) { Assert.IsTrue(false); } Assert.IsTrue(true); }
public async Task TrackFriendNumber_FriendRequest_GivenDay() { //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.CreateFriendRequestAsync(1, 2); int avarageFriends = await userAnalysisService.FriendRequest_GivenDay(DateTimeOffset.UtcNow); if (avarageFriends != 1) { Assert.IsTrue(false); } Assert.IsTrue(true); }
public async Task TrackFriendNumber_GetLast12MonthsFriendRequestTrend() { //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.CreateFriendRequestAsync(1, 2); IEnumerable <int> avarageFriends = await userAnalysisService.GetLast12MonthsFriendRequestTrend(); if (avarageFriends == null) { Assert.IsTrue(false); } if (avarageFriends.Count() == 0) { Assert.IsTrue(false); } if (avarageFriends.Count() != 366) { Assert.IsTrue(false); } Assert.IsTrue(true); }
public async Task TrackSuspendedAccounts_Countaccounts(string status) { int expected = 20; 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); IEnumerable <UserAccountModel> models = await userAccountRepository.GetAllAccounts(); List <UserAccountModel> userAccountModels = new List <UserAccountModel>(); foreach (var model in models) { model.AccountStatus = "Suspended"; await userAccountRepository.UpdateAccountStatus(model.Id, model.AccountStatus); } int count = await userAnalysisService.GetNumOfSuspendedUsers(); if (expected == count) { Assert.IsTrue(true); } else { Assert.IsTrue(false); } }