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);
            }
        }
Пример #2
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 CreateReportAsync_CreateReport_ReportCreated(int userId1, int userId2, string report)
        {
            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 <IValidationService> validationService = new Mock <IValidationService>();

            IUserInteractionService userInteractionService = new UserInteractionService(friendBlockListRepo.Object, friendListRepo.Object, friendRequestListRepo.Object, userReportsRepo.Object, validationService.Object);


            UserReportsModel model = new UserReportsModel();

            model.ReportedId  = userId1;
            model.ReportingId = userId2;
            model.Report      = report;
            try
            {
                await userInteractionService.CreateReportAsync(model);

                Assert.IsTrue(true);
            }
            catch
            {
                Assert.IsTrue(false);
            }
        }
        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 GetAllBlockingUsers_CreatBlock_BlockCreated(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.CreateBlockAsync(userId1, userId2);

                IEnumerable <FriendsListJunctionModel> friendsListJunctionModels = await userInteractionService.GetAllBlockingUsers(userId1);
            }
            catch
            {
                Assert.IsTrue(false);
            }
        }
Пример #6
0
 public FormLoad(ImageLoaderService imageLoaderService, UserInteractionService interactionService)
 {
     _imageLoaderService = imageLoaderService;
     _interactionService = interactionService;
     InitializeComponent();
     _baseSearchPath = null;
 }
Пример #7
0
 protected void HideSpinnerAndRedirectToViewModel <T>(bool makeItFirst) where T : BaseViewModel
 {
     UserInteractionService.HideSpinner();
     if (makeItFirst)
     {
         ShowViewModelAndMakeItTheFirstOne <T>();
     }
     else
     {
         ShowViewModel <T>();
     }
 }
        public async Task CreateReportAsync_CreateReport_ReportCreated(int userId1, int userId2, string report)
        {
            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);

            UserReportsModel model = new UserReportsModel();

            model.ReportedId  = userId1;
            model.ReportingId = userId2;
            model.Report      = report;
            try
            {
                await userInteractionService.CreateReportAsync(model);

                IEnumerable <UserReportsModel> userReports = await userReportsRepo.GetAllReports();

                if (userReports == null)
                {
                    Assert.IsTrue(false);
                }
                if (userReports.Count() == 0)
                {
                    Assert.IsTrue(false);
                }
                foreach (var userReport in userReports)
                {
                    if (userReport.Report == report && userReport.ReportedId == userId1 && userReport.ReportingId == userId2)
                    {
                        Assert.IsTrue(true);
                    }
                }
            }
            catch
            {
                Assert.IsTrue(false);
            }
        }
Пример #9
0
        //protected abstract void DoTopRightButtonCommand();

        public override async void Start()
        {
            base.Start();

            try
            {
                UserInteractionService.ShowSpinner();

                await FillCollectionAsync();

                UserInteractionService.HideSpinner();
            }
            catch (Exception ex)
            {
                LogExceptionHideSpinnerAndSetStatusMessage(ex);
            }
        }
Пример #10
0
        private async Task AuthenticateCommandExecuteAsync()
        {
            AccountResponse accountResponse = await _authService.LoginAsync(Username, Password);

            if (accountResponse == null)
            {
                return;
            }

            if (!accountResponse.Success)
            {
                UserInteractionService.ShowToast("Casa caiu!");
            }
            else
            {
                UserInteractionService.ShowToast("Autenticado...");
            }
        }
Пример #11
0
        public FormMain(FormAddBookmark formAddBookmark, BookmarkService bookmarkService, FormSettings formSettings, ApplicationSettingsService applicationSettingsService, ImageCacheService imageCacheService, ImageLoaderService imageLoaderService,
                        ILifetimeScope scope, UserInteractionService interactionService)
        {
            _formAddBookmark            = formAddBookmark;
            _bookmarkService            = bookmarkService;
            _formSettings               = formSettings;
            _applicationSettingsService = applicationSettingsService;
            _applicationSettingsService.LoadSettings();

            _imageCacheService  = imageCacheService;
            _imageLoaderService = imageLoaderService;
            _scope = scope;
            _interactionService = interactionService;

            InitializeComponent();
            _imageViewFormList = new List <FormImageView>();
            _windowTitle       = "Image Viewer - " + Application.ProductVersion;
        }
        public async Task GetAllBlockingUsers_CreatBlock_BlockCreated(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.CreateBlockAsync(userId1, userId2);

                IEnumerable <FriendsListJunctionModel> friendsListJunctionModels = await userInteractionService.GetAllBlockingUsers(userId1);

                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);
            }
        }
Пример #13
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);
        }
        public async Task RemoveFriendBlockAsync_RemoveBlock_BlockRemoved(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.CreateBlockAsync(userId1, userId2);

                await userInteractionService.RemoveFriendBlockAsync(userId1, userId2);


                IEnumerable <FriendsListJunctionModel> friendsListJunctionModels = await friendBlockListRepo.GetAllFriendBlocks();

                if (friendsListJunctionModels == null)
                {
                    Assert.IsTrue(false);
                }
                if (friendsListJunctionModels.Count() == 0)
                {
                    Assert.IsTrue(true);
                }
            }
            catch
            {
                Assert.IsTrue(false);
            }
        }
        public async Task RemoveReportAsync_RemoveReport_ReportRemoved(int userId1, int userId2, string report)
        {
            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);



            UserReportsModel model = new UserReportsModel();

            model.ReportedId  = userId1;
            model.ReportingId = userId2;
            model.Report      = report;
            try
            {
                await userInteractionService.CreateReportAsync(model);

                await userInteractionService.RemoveReportAsync(1);
            }
            catch
            {
                Assert.IsTrue(false);
            }
        }
Пример #16
0
        public async Task SeedUsers(int seedAmount)
        {
            await TestCleaner.CleanDatabase();

            IDataGateway                       dataGateway       = new SQLServerGateway();
            IConnectionStringData              connectionString  = new ConnectionStringData();
            IListingRepository                 listingRepository = new ListingRepository(dataGateway, connectionString);
            ICollaborationRepository           listingCollaborationRepository    = new CollaborationRepository(dataGateway, connectionString);
            IRelationshipRepository            listingRelationshipRepository     = new RelationshipRepository(dataGateway, connectionString);
            ITeamModelRepository               listingTeamModelRepository        = new TeamModelRepository(dataGateway, connectionString);
            IUserAccountRepository             userAccountRepository             = new UserAccountRepository(dataGateway, connectionString);
            IUserProfileRepository             userProfileRepository             = new UserProfileRepository(dataGateway, connectionString);
            IUserAccountSettingsRepository     userAccountSettingsRepository     = new UserAccountSettingRepository(dataGateway, connectionString);
            IAssignmentPolicyRepository        assignmentPolicyRepository        = new AssignmentPolicyRepository(dataGateway, connectionString);
            IAssignmentPolicyPairingRepository assignmentPolicyPairingRepository = new AssignmentPolicyPairingRepository(dataGateway, connectionString);
            IScopeRepository                   scopeRepsitory           = new ScopeRepository(dataGateway, connectionString);
            IClaimRepository                   claimRepository          = new ClaimRepository(dataGateway, connectionString);
            IScopeClaimRepository              scopeClaimRepository     = new ScopeClaimRepository(dataGateway, connectionString);
            IUserScopeClaimRepository          userScopeClaimRepository = new UserScopeClaimRepository(dataGateway, connectionString);
            IScopeService                      scopeService             = new ScopeService(claimRepository, scopeRepsitory, scopeClaimRepository, userScopeClaimRepository);
            ICryptographyService               cryptographyService      = new CryptographyService(userAccountRepository);
            IAssignmentPolicyService           assignmentPolicyService  = new AssignmentPolicyService(assignmentPolicyRepository, assignmentPolicyPairingRepository, scopeRepsitory, scopeService);
            IClaimsService                     claimService             = new ClaimsService(claimRepository, scopeRepsitory, scopeClaimRepository, userScopeClaimRepository);
            IListingCreationService            listingCreationService   = new ListingCreationService(listingRepository, listingCollaborationRepository, listingRelationshipRepository,
                                                                                                     listingTeamModelRepository);

            var accounts = await userAccountRepository.GetAllAccounts();

            var accountSettings = await userAccountSettingsRepository.GetAllSettings();

            IUserChannelsRepo userChannelsRepo = new UserChannelsRepo(dataGateway, connectionString);
            var userChannels = await userChannelsRepo.GetAllUserChannelsAsync();

            foreach (var userChannel in userChannels)
            {
                await userChannelsRepo.DeleteUserChannelsByIdAsync(userChannel.Id);
            }

            await DataAccessTestHelper.ReseedAsync("UserChannels", 0, connectionString, dataGateway);

            IMessagesRepo messagesRepo = new MessagesRepo(dataGateway, connectionString);
            var           messages     = await messagesRepo.GetAllMessagesAsync();

            foreach (var message in messages)
            {
                await messagesRepo.DeleteMessageByIdAsync(message.Id);
            }

            await DataAccessTestHelper.ReseedAsync("Messages", 0, connectionString, dataGateway);

            IChannelsRepo channelsRepo = new ChannelsRepo(dataGateway, connectionString);
            var           channels     = await channelsRepo.GetAllChannelsAsync();

            foreach (var channel in channels)
            {
                await channelsRepo.DeleteChannelbyIdAsync(channel.Id);
            }


            IAccountVerificationRepo accountVerification = new AccountVerificationRepo(dataGateway, connectionString);
            var verfications = await accountVerification.GetAllAccountVerifications();

            foreach (var verfication in verfications)
            {
                await accountVerification.DeleteAccountVerificationById(verfication.Id);
            }

            await DataAccessTestHelper.ReseedAsync("AccountVerification", 0, connectionString, dataGateway);

            IPublicUserProfileRepo publicUserProfileRepo = new PublicUserProfileRepo(dataGateway, connectionString);
            var publicProfiles = await publicUserProfileRepo.GetAllPublicProfiles();

            foreach (var profile in publicProfiles)
            {
                await publicUserProfileRepo.DeletePublicProfileById(profile.Id);
            }

            await DataAccessTestHelper.ReseedAsync("PublicUserProfile", 0, connectionString, dataGateway);

            if (accounts != null)
            {
                var numRows = accounts.ToList().Count;

                for (int i = 1; i <= numRows; ++i)
                {
                    await userAccountSettingsRepository.DeleteUserAccountSettingsByUserId(i);
                }
            }

            await TestCleaner.CleanDatabase();

            await DataAccessTestHelper.ReseedAsync("UserAccountSettings", 0, connectionString, dataGateway);


            IUserAccountService userAccountService = new UserAccountService(userAccountRepository);
            IUserProfileService userProfileService = new UserProfileService(userProfileRepository);

            var assignedScopes = new List <ScopeModel>();
            var namedScopes    = new List <string>()
            {
                "friends_list:read,", "friends_list:write,", "friends_list:delete,", "friends_list:block,",
                "friends_list:approve,", "user_profile:read,", "user_profile:report,", "user_profile:write,", "user_profile.friends_list.status:read,",
                "application:read,", "user_profile.visibility:read,", "user_profile.photo:upload,", "messaging:send,", "messaging:get,", "messaging.users:get,", "messaging.channels:addUser,", "messaging.channels:removeUser,", "channels.user:getall,", "channels:create,", "channels:getowner,", "channels:delete,", "message:delete,", "channel:setonline,", "channel:setoffline,",
                "account:delete,", "account:passwordchange,", "account.fontszie:change,", "account.email:change,", "account.fontSize:get,", "account.fontstyle:change,", "account.fontstyle:get,", "account.theme:change,", "account.theme:get,",
                "listings:read,", "listings:write,"
            };
            var claims = new List <ClaimModel>();

            claims.Add(new ClaimModel()
            {
                Type      = "channel_owner",
                Value     = "false",
                IsDefault = true
            });
            claims.Add(new ClaimModel()
            {
                Type      = "Moderator",
                Value     = "false",
                IsDefault = true
            });

            var currentClaims = await claimService.GetAllClaims();

            foreach (var claim in claims)
            {
                foreach (var currentClaim in currentClaims)
                {
                    if (claim.Type == currentClaim.Type)
                    {
                        continue;
                    }
                }

                await claimService.CreateClaim(claim);
            }

            var databaseClaims = await claimService.GetAllClaims();

            foreach (var scope in namedScopes)
            {
                assignedScopes.Add(new ScopeModel()
                {
                    Type        = scope,
                    Claims      = databaseClaims,
                    Description = null,
                    IsDefault   = true
                });
            }

            assignedScopes.ForEach(async x => await scopeService.CreateScope(x));
            var scopes             = (await scopeService.GetAllScopes()).ToList();
            var assignmentPolicies = await assignmentPolicyService.CreateAssignmentPolicy(new BusinessModels.UserAccessControl.AssignmentPolicyModel()
            {
                Default             = true,
                Name                = "DefaultAccessPolicy",
                AssignedScopes      = scopes,
                Priority            = 1,
                RequiredAccountType = "user"
            });

            var adminPolicies = await assignmentPolicyService.CreateAssignmentPolicy(new BusinessModels.UserAccessControl.AssignmentPolicyModel()
            {
                Default             = true,
                Name                = "DefaultAdminPolicy",
                AssignedScopes      = scopes,
                Priority            = 1,
                RequiredAccountType = "admin"
            });

            PublicUserProfileManager publicUserProfileManager = new PublicUserProfileManager(new PublicUserProfileService(publicUserProfileRepo, new ValidationService(userAccountService, userProfileService)));
            IAccountVerificationRepo accountVerificationRepo  = new AccountVerificationRepo(new SQLServerGateway(), new ConnectionStringData());

            IDictionary <string, string> _testConfigKeys = new Dictionary <string, string>();

            _testConfigKeys.Add("Sender", "*****@*****.**");
            _testConfigKeys.Add("TrackOpens", "true");
            _testConfigKeys.Add("Subject", "Welcome!");
            _testConfigKeys.Add("TextBody", "Welcome to InfiniMuse!");
            _testConfigKeys.Add("MessageStream", "outbound");
            _testConfigKeys.Add("Tag", "Welcome");
            _testConfigKeys.Add("HtmlBody", "Thank you for registering! Please confirm your account with the link: <a href='{0}'>Confirm Your Account!</a><strong>Once confirmed you will have access to the features.</strong>");

            IConfiguration configuration = new ConfigurationBuilder()
                                           .AddInMemoryCollection(_testConfigKeys)
                                           .Build();
            EmailService emailService = new EmailService(new UserAccountRepository
                                                             (new SQLServerGateway(), new ConnectionStringData()), new AccountVerificationRepo
                                                             (new SQLServerGateway(), new ConnectionStringData()), new UserAccountService(new UserAccountRepository
                                                                                                                                              (new SQLServerGateway(), new ConnectionStringData())), configuration);

            for (int i = 1; i < seedAmount; ++i)
            {
                UserAccountModel         userAccountModel         = new UserAccountModel();
                UserProfileModel         userProfileModel         = new UserProfileModel();
                UserAccountSettingsModel userAccountSettingsModel = new UserAccountSettingsModel();

                userAccountModel.Id            = i;
                userAccountModel.Username      = "******" + i;
                userAccountModel.Password      = "" + i;
                userAccountModel.Salt          = "" + i;
                userAccountModel.EmailAddress  = "TestEmailAddress" + i;
                userAccountModel.AccountType   = "user";
                userAccountModel.AccountStatus = "TestAccountStatus" + i;
                userAccountModel.CreationDate  = DateTimeOffset.UtcNow;
                userAccountModel.UpdationDate  = DateTimeOffset.UtcNow;

                userProfileModel.Id            = i;
                userProfileModel.FirstName     = "TestFirstName" + i;
                userProfileModel.Surname       = "TestSurname" + i;
                userProfileModel.DateOfBirth   = DateTimeOffset.UtcNow;
                userProfileModel.UserAccountId = userAccountModel.Id;

                userAccountSettingsModel.Id         = i;
                userAccountSettingsModel.UserId     = userAccountModel.Id;
                userAccountSettingsModel.FontSize   = 12;
                userAccountSettingsModel.FontStyle  = "Default";
                userAccountSettingsModel.ThemeColor = "Light";

                await userAccountRepository.CreateAccount(userAccountModel);

                await cryptographyService.newPasswordEncryptAsync("T" + i, i);

                await userProfileRepository.CreateUserProfile(userProfileModel);

                await userAccountSettingsRepository.CreateUserAccountSettings(userAccountSettingsModel);

                PublicUserProfileModel publicUserProfileModel = new PublicUserProfileModel();
                publicUserProfileModel.UserId = userAccountModel.Id;

                publicUserProfileModel.Description = "My name is " + userAccountModel.Username;
                publicUserProfileModel.Visibility  = "Public";
                publicUserProfileModel.Age         = userAccountModel.Id + 20;
                publicUserProfileModel.Hobbies     = "These are my hobbies";
                publicUserProfileModel.Intrests    = "These are my intrests";
                publicUserProfileModel.Height      = "This is how tall I am";
                await publicUserProfileManager.CeatePublicUserProfileAsync(publicUserProfileModel);

                await emailService.CreateVerificationToken(publicUserProfileModel.UserId);
            }

            IMessagingService messagingService = new MessagingService(messagesRepo, channelsRepo, userChannelsRepo, userAccountRepository);

            ChannelModel model = new ChannelModel();

            model.OwnerId = 1;
            model.Name    = "Jakes Group";
            await messagingService.CreateChannelAsync(model);

            for (int i = 2; i < 19; i++)
            {
                await messagingService.AddUserToChannelAsync(i, 1);
            }

            IFriendListRepo friendListRepo = new FriendListRepo(dataGateway, connectionString);

            IFriendRequestListRepo friendRequestListRepo = new FriendRequestListRepo(dataGateway, connectionString);

            IFriendBlockListRepo friendBlockListRepo = new FriendBlockListRepo(dataGateway, connectionString);

            IEnumerable <FriendsListJunctionModel> friends = await friendListRepo.GetAllFriends();

            foreach (var friend in friends)
            {
                await friendListRepo.DeleteFriendListbyId(friend.Id);
            }

            await DataAccessTestHelper.ReseedAsync("FriendsList", 0, connectionString, dataGateway);

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

            foreach (var request in requets)
            {
                await friendRequestListRepo.DeleteFriendRequestListbyId(request.Id);
            }

            await DataAccessTestHelper.ReseedAsync("FriendRequestList", 0, connectionString, dataGateway);

            IEnumerable <FriendsListJunctionModel> blocks = await friendBlockListRepo.GetAllFriendBlocks();

            foreach (var block in blocks)
            {
                await friendBlockListRepo.DeleteFriendBlockbyId(block.Id);
            }

            await DataAccessTestHelper.ReseedAsync("FriendBlockList", 0, connectionString, dataGateway);


            for (int i = 0; i < 20; i++)
            {
                BusinessCollaborationModel newBusinessCollaborationModel = new BusinessCollaborationModel();
                BusinessListingModel       newBusinessListingModel       = new BusinessListingModel();

                newBusinessCollaborationModel.Title   = "TestTitle" + i;
                newBusinessCollaborationModel.Details = "TestDetails" + i;
                newBusinessCollaborationModel.City    = "TestCity" + i;
                newBusinessCollaborationModel.State   = "TestState" + i;
                newBusinessCollaborationModel.NumberOfParticipants = i;
                newBusinessCollaborationModel.InPersonOrRemote     = "InpersonOrRemoteTest" + i;
                newBusinessCollaborationModel.UserAccountId        = i;
                newBusinessCollaborationModel.CollaborationType    = "TestcollaborationType" + i;
                newBusinessCollaborationModel.InvolvementType      = "InvolvementType" + i;
                newBusinessCollaborationModel.Experience           = "Testexperience" + i;
                newBusinessCollaborationModel.CollaborationType    = "TestCollaborationType" + i;
                newBusinessCollaborationModel.InvolvementType      = "TestInvolvementType" + i;
                newBusinessCollaborationModel.Experience           = "TestExperience" + i;


                await listingCreationService.CreateListing(newBusinessCollaborationModel);
            }
            for (int i = 21; i < 40; i++)
            {
                BusinessRelationshipModel newBusinessRelationshipModel = new BusinessRelationshipModel();
                BusinessListingModel      newBusinessListingModel1     = new BusinessListingModel();

                newBusinessRelationshipModel.Title   = "TestTitle" + i;
                newBusinessRelationshipModel.Details = "TestDetails" + i;
                newBusinessRelationshipModel.City    = "TestCity" + i;
                newBusinessRelationshipModel.State   = "TestState" + i;
                newBusinessRelationshipModel.NumberOfParticipants = i;
                newBusinessRelationshipModel.InPersonOrRemote     = "InpersonOrRemoteTest" + i;
                newBusinessRelationshipModel.UserAccountId        = i;
                newBusinessRelationshipModel.RelationshipType     = "TestcollaborationType" + i;
                newBusinessRelationshipModel.Age              = 21;
                newBusinessRelationshipModel.Interests        = "TestInterests" + i;
                newBusinessRelationshipModel.GenderPreference = "TestGenderPreference" + i;

                await listingCreationService.CreateListing(newBusinessRelationshipModel);
            }
            for (int i = 41; i < 60; i++)
            {
                BusinessTeamModel    newBusinessTeamModel     = new BusinessTeamModel();
                BusinessListingModel newBusinessListingModel1 = new BusinessListingModel();

                newBusinessTeamModel.Title   = "TestTitle" + i;
                newBusinessTeamModel.Details = "TestDetails" + i;
                newBusinessTeamModel.City    = "TestCity" + i;
                newBusinessTeamModel.State   = "TestState" + i;
                newBusinessTeamModel.NumberOfParticipants = i;
                newBusinessTeamModel.InPersonOrRemote     = "InpersonOrRemoteTest" + i;
                newBusinessTeamModel.UserAccountId        = i + 1;
                newBusinessTeamModel.TeamType             = "TestTeamType" + i;
                newBusinessTeamModel.GameType             = "TestGameType" + i;
                newBusinessTeamModel.Platform             = "TestPlatform" + i;
                newBusinessTeamModel.Experience           = "TestExperience" + i;


                await listingCreationService.CreateListing(newBusinessTeamModel);
            }

            IUserReportsRepo          userReportsRepo          = new UserReportsRepo(dataGateway, connectionString);
            IValidationService        validationService        = new ValidationService(userAccountService, userProfileService);
            IPublicUserProfileService publicUserProfileService = new PublicUserProfileService(publicUserProfileRepo, validationService);

            IUserInteractionService userInteractionService = new UserInteractionService(friendBlockListRepo, friendListRepo, friendRequestListRepo, userReportsRepo, validationService);
            IFriendListManager      friendListManager      = new FriendListManager(userAccountRepository, publicUserProfileService, userInteractionService);

            for (int i = 10; i < 15; i++)
            {
                await friendListManager.RequestFriendAsync(1, i);
            }

            await friendListManager.RequestFriendAsync(18, 1);


            for (int i = 2; i < 10; i++)
            {
                await friendListManager.RequestFriendAsync(1, i);

                await friendListManager.ConfirmFriendAsync(1, i);
            }

            for (int i = 3; i < 10; i++)
            {
                await friendListManager.RequestFriendAsync(2, i);

                await friendListManager.ConfirmFriendAsync(2, i);
            }

            await friendListManager.BlockFriendAsync(19, 1);

            MessageModel messageModel = new MessageModel();

            messageModel.ChannelId = 1;
            messageModel.UserId    = 1;
            messageModel.Message   = "Hi Tim";
            await messagingService.SendMessageAsync(messageModel);

            messageModel           = new MessageModel();
            messageModel.ChannelId = 1;
            messageModel.UserId    = 2;
            messageModel.Message   = "Whats up Jake";
            await messagingService.SendMessageAsync(messageModel);

            model         = new ChannelModel();
            model.OwnerId = 3;
            model.Name    = "Richards Group";
            await messagingService.CreateChannelAsync(model);

            await messagingService.AddUserToChannelAsync(1, 2);

            await messagingService.AddUserToChannelAsync(2, 2);

            messageModel           = new MessageModel();
            messageModel.ChannelId = 2;
            messageModel.UserId    = 3;
            messageModel.Message   = "Hi Jake and Tim";
            await messagingService.SendMessageAsync(messageModel);

            messageModel           = new MessageModel();
            messageModel.ChannelId = 2;
            messageModel.UserId    = 1;
            messageModel.Message   = "Whats up Richard how are you doing";
            await messagingService.SendMessageAsync(messageModel);

            messageModel           = new MessageModel();
            messageModel.ChannelId = 2;
            messageModel.UserId    = 3;
            messageModel.Message   = "Im Chilling";
            await messagingService.SendMessageAsync(messageModel);

            messageModel           = new MessageModel();
            messageModel.ChannelId = 2;
            messageModel.UserId    = 3;
            messageModel.Message   = "Just doing some homework";
            await messagingService.SendMessageAsync(messageModel);

            messageModel           = new MessageModel();
            messageModel.ChannelId = 2;
            messageModel.UserId    = 1;
            messageModel.Message   = "Oh nice, I started spring break this week and I finished all of my homework a few days ago so im just relaxing playing some warzone";
            await messagingService.SendMessageAsync(messageModel);

            messageModel           = new MessageModel();
            messageModel.ChannelId = 2;
            messageModel.UserId    = 3;
            messageModel.Message   = "Oh sweet";
            await messagingService.SendMessageAsync(messageModel);

            messageModel           = new MessageModel();
            messageModel.ChannelId = 2;
            messageModel.UserId    = 2;
            messageModel.Message   = "Whats up guys its me Tim";
            await messagingService.SendMessageAsync(messageModel);

            messageModel           = new MessageModel();
            messageModel.ChannelId = 2;
            messageModel.UserId    = 3;
            messageModel.Message   = "Hey Tim";
            await messagingService.SendMessageAsync(messageModel);

            messageModel           = new MessageModel();
            messageModel.ChannelId = 2;
            messageModel.UserId    = 1;
            messageModel.Message   = "Whats up tim";
            await messagingService.SendMessageAsync(messageModel);

            messageModel           = new MessageModel();
            messageModel.ChannelId = 2;
            messageModel.UserId    = 2;
            messageModel.Message   = "Nothing much guys";
            await messagingService.SendMessageAsync(messageModel);

            messageModel           = new MessageModel();
            messageModel.ChannelId = 2;
            messageModel.UserId    = 1;
            messageModel.Message   = "You guys wanna hop on warzone with me";
            await messagingService.SendMessageAsync(messageModel);
        }
Пример #17
0
    public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
    {
        Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(LANGUAGE_TAG_US);
        Thread.CurrentThread.CurrentCulture   = CultureInfo.GetCultureInfo(LANGUAGE_TAG_US);

        UIApplication uiApp = commandData.Application;
        UIDocument    uiDoc = commandData.Application.ActiveUIDocument;
        Document      doc   = commandData.Application.ActiveUIDocument.Document;

        var rom = new RevitObjectManager();
        var ogc = new ObjectToGeometryConverter();

        List <Level> allLevels = UserInteractionService.LetUserPickLevels(doc, rom);

        if (allLevels.Count == 0)
        {
            TaskDialog.Show("Plugin abort", "User did not select any levels, Plugin aborts.");
            return(Result.Cancelled);
        }

        List <Scenario> allScenarios = new List <Scenario>();
        List <Stairs>   allStairs    = rom.GetAllStairs(doc);

        foreach (Level level in allLevels)
        {
            GeometryFactory.Reset();
            ogc.Reset();

            List <Room> rooms = rom.GetAllRoomsFromLevel(level);

            if (!rom.RoomsOnCurrentLevelPlaced(rooms))
            {
                continue;
            }

            List <FamilyInstance> doors = rom.GetAllDoorsFromLevel(level);
            List <KeyValuePair <string, List <Stairs> > > stairs = rom.GetAllStairsFromLevel(uiDoc, allStairs, level);

            var originList           = new List <Polygon2D>();
            var intermediateList     = new List <Polygon2D>(); // unused... probably for stairs that pass through a level
            var destinationList      = new List <Polygon2D>();
            var gatheringLineList    = new List <Segment2D>();
            var wallList             = new List <Segment2D>();
            var solidList            = new List <Polygon2D>();
            var roomBoundaryPolygons = new List <Polygon2D>();

            // assemble list of all walls and the most outer boundary wall
            foreach (Room currentRoom in rooms)
            {
                if (currentRoom.Location != null)
                {
                    List <Geometry2D> allWallsOfRoom = ogc.GetWallsOfRoomAsGeometry2D(uiDoc, currentRoom);
                    wallList.AddRange(ogc.GetOuterBoundaryWall(allWallsOfRoom));
                    roomBoundaryPolygons.Add(ogc.OuterBoundaryPolygon);// also adds nulls... and duplicates?!
                    wallList.AddRange(ogc.GetObstacleWalls(allWallsOfRoom));
                    solidList.AddRange(ogc.GetObstacleSolids(allWallsOfRoom));
                }
            }

            foreach (var currentPair in stairs)
            {
                List <Polygon2D> allStairAreas = new List <Polygon2D>();

                if (currentPair.Key.Equals(RevitObjectManager.BASE_LEVEL_KEY))
                {
                    foreach (Stairs currentStairs in currentPair.Value)
                    {
                        Polygon2D stairArea = ogc.GetStairAreaPolygon(uiDoc, currentStairs, RevitObjectManager.BASE_LEVEL_KEY);

                        if (GeoAdditionals.ConvertedRoomsContainStairArea(roomBoundaryPolygons, stairArea))
                        {
                            allStairAreas.Add(stairArea);
                        }
                    }
                }
                else if (currentPair.Key.Equals(RevitObjectManager.TOP_LEVEL_KEY))
                {
                    foreach (Stairs currentStairs in currentPair.Value)
                    {
                        Polygon2D stairArea = ogc.GetStairAreaPolygon(uiDoc, currentStairs, RevitObjectManager.TOP_LEVEL_KEY);

                        if (GeoAdditionals.ConvertedRoomsContainStairArea(roomBoundaryPolygons, stairArea))
                        {
                            allStairAreas.Add(stairArea);
                        }
                    }
                }

                originList.AddRange(allStairAreas);
                destinationList.AddRange(allStairAreas);
            }

            List <Geometry2D> convertedDoors = ogc.CreateDoorSegments(uiDoc, doors);
            List <Segment2D>  doorSegments   = new List <Segment2D>();

            foreach (Geometry2D currentDoor in convertedDoors)
            {
                if (currentDoor.GetType() == typeof(Segment2D))
                {
                    doorSegments.Add((Segment2D)currentDoor);
                }
                else if (currentDoor.GetType() == typeof(Polygon2D))
                {
                    originList.Add((Polygon2D)currentDoor);
                    destinationList.Add((Polygon2D)currentDoor);
                }
            }

            wallList = ogc.RemoveDotWalls(wallList);
            wallList = ogc.CreateDoorOpenings(doorSegments, wallList);

            wallList        = ogc.SetCorrectWallNames(wallList);
            solidList       = ogc.SetCorrectPolygonNames(solidList, ObjectToGeometryConverter.SOLID_OBJECT_NAME);
            originList      = ogc.SetCorrectPolygonNames(originList, ObjectToGeometryConverter.ORIGIN_OBJECT_NAME);
            destinationList = ogc.SetCorrectPolygonNames(destinationList, ObjectToGeometryConverter.DESTINATION_OBJECT_NAME);

            double[] minCoords       = GeometryFactory.GetMinimumCoordinates();
            double[] maxCoords       = GeometryFactory.GetMaximumCoordinates();
            Scenario currentScenario = new Scenario(level.Name, minCoords, maxCoords, originList, intermediateList, gatheringLineList, destinationList, wallList, solidList);
            allScenarios.Add(currentScenario);
        }

        var converter       = new OutputModelConverter();
        var simulatorOutput = converter.ToSimulator(allScenarios);

        var saveFileService = new UserInteractionService();

        saveFileService.SaveSimulatorToXml(simulatorOutput);

        return(Result.Succeeded);
    }
Пример #18
0
 protected void HideSpinnerAndSetStatusMessage(string message)
 {
     UserInteractionService.HideSpinner();
 }