public async Task GetAllUserFriendRequests_CreatRequest_RequestCreated(int userId1, int userId2)
        {
            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.CreateFriendRequestAsync(userId1, userId2);

                IEnumerable <FriendsListJunctionModel> friendsListJunctionModels = await userInteractionService.GetAllUserFriendRequests(userId1);
            }
            catch
            {
                Assert.IsTrue(false);
            }
        }
        public async Task RemoveFriendRequestAsync_RemoveRequest_RequestRemoved(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.CreateFriendRequestAsync(userId1, userId2);

                await userInteractionService.RemoveFriendRequestAsync(userId1, userId2);
            }
            catch
            {
                Assert.IsTrue(false);
            }
        }
Пример #3
0
        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 CreateFriendRequestAsync_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.CreateFriendRequestAsync(userId1, userId2);

                IEnumerable <FriendsListJunctionModel> friendsListJunctionModels = await friendRequestListRepo.GetAllFriendRequests();

                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);
            }
        }
Пример #5
0
        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);
        }