Esempio n. 1
0
        public async Task GetAllLoginAttempts_AtLeastTwoLoginAttemptsExist_ReturnsCorrectNumberOfLoginAttempts
            (int numLoginAttempts)
        {
            // Arrange
            ILoginAttemptsRepository loginAttemptsRepository =
                new LoginAttemptsRepository(new SQLServerGateway(), new ConnectionStringData());

            // Act
            IEnumerable <LoginAttemptsModel> loginAttempts = await loginAttemptsRepository.GetAllLoginAttempts();

            // Assert
            int i = 1;

            foreach (LoginAttemptsModel loginAttempt in loginAttempts)
            {
                if (loginAttempt.Id == i)
                {
                    ++i;
                    continue;
                }
            }

            if (i == numLoginAttempts + 1)
            {
                Assert.IsTrue(true);
            }
            else
            {
                Assert.IsTrue(false);
            }
        }
Esempio n. 2
0
        public async Task CleanUp()
        {
            IDataGateway             dataGateway             = new SQLServerGateway();
            IConnectionStringData    connectionString        = new ConnectionStringData();
            ILoginAttemptsRepository loginAttemptsRepository = new LoginAttemptsRepository(dataGateway, connectionString);
            var loginAttempts = await loginAttemptsRepository.GetAllLoginAttempts();

            foreach (var loginAttempt in loginAttempts)
            {
                await loginAttemptsRepository.DeleteLoginAttemptsById(loginAttempt.Id);
            }
            await DataAccessTestHelper.ReseedAsync("LoginAttempts", 0, connectionString, dataGateway);
        }
Esempio n. 3
0
        public async Task GetAllLoginAttempts_AtLeastTwoLoginAttemptsExist_ExecutionTimeLessThan400Milliseconds
            (long expectedMaxExecutionTime)
        {
            // Arrange
            ILoginAttemptsRepository loginAttemptsRepository = new LoginAttemptsRepository
                                                                   (new SQLServerGateway(), new ConnectionStringData());

            // Act
            var timer = Stopwatch.StartNew();
            await loginAttemptsRepository.GetAllLoginAttempts();

            timer.Stop();

            var actualExecutionTime = timer.ElapsedMilliseconds;

            Debug.WriteLine("Actual Execution Time: " + actualExecutionTime);

            // Assert
            Assert.IsTrue(actualExecutionTime <= expectedMaxExecutionTime);
        }
        public static async Task CleanDatabase()
        {
            IDataGateway                        dataGateway                        = new SQLServerGateway();
            IConnectionStringData               connectionString                   = new ConnectionStringData();
            IUserAccountRepository              userAccountRepository              = new UserAccountRepository(dataGateway, connectionString);
            IUserProfileRepository              userProfileRepository              = new UserProfileRepository(dataGateway, connectionString);
            IUserAccountCodeRepository          userAccountCodeRepository          = new UserAccountCodeRepository(dataGateway, connectionString);
            IUserAccountSettingsRepository      userAccountSettingsRepository      = new UserAccountSettingRepository(dataGateway, connectionString);
            ILoginAttemptsRepository            loginAttemptsRepository            = new LoginAttemptsRepository(dataGateway, connectionString);
            IResourceRepository                 resourceRepository                 = new ResourceRepository(dataGateway, connectionString);
            IClaimRepository                    claimRepository                    = new ClaimRepository(dataGateway, connectionString);
            IScopeRepository                    scopeRepository                    = new ScopeRepository(dataGateway, connectionString);
            IScopeClaimRepository               scopeClaimRepository               = new ScopeClaimRepository(dataGateway, connectionString);
            IUserScopeRepository                userScopeRepository                = new UserScopeRepository(dataGateway, connectionString);
            IUserClaimRepository                userClaimRepository                = new UserClaimRepository(dataGateway, connectionString);
            IAssignmentPolicyRepository         assignmentPolicyRepository         = new AssignmentPolicyRepository(dataGateway, connectionString);
            IAssignmentPolicyPairingRepository  assignmentPolicyPairingRepository  = new AssignmentPolicyPairingRepository(dataGateway, connectionString);
            IUserScopeClaimRepository           userScopeClaimRepository           = new UserScopeClaimRepository(dataGateway, connectionString);
            IAccessPolicyRepository             accessPolicyRepository             = new AccessPolicyRepository(dataGateway, connectionString);
            IAccessPolicyPairingRepository      accessPolicyPairingRepository      = new AccessPolicyPairingRepository(dataGateway, connectionString);
            ITraditionalListingSearchRepository traditionalListingSearchRepository = new TraditionalListingSearchRepository(dataGateway, connectionString);


            var accounts = await userAccountRepository.GetAllAccounts();

            var profiles = await userProfileRepository.GetAllUserProfiles();

            var accountCodes = await userAccountCodeRepository.GetAllUserAccountCodes();

            var accountSettings = await userAccountSettingsRepository.GetAllSettings();

            var loginAttempts = await loginAttemptsRepository.GetAllLoginAttempts();

            var resources = await resourceRepository.GetAllResources();

            var claims = await claimRepository.GetAllClaims();

            var scopes = await scopeRepository.GetAllScopes();

            var scopeClaims = await scopeClaimRepository.GetAllScopeClaims();

            var userClaims = await userClaimRepository.GetAllUserClaims();

            var userScopes = await userScopeRepository.GetAllUserScopes();

            var assignmentPolicies = await assignmentPolicyRepository.GetAllAssignmentPolicies();

            var assignmentPolicyPairings = await assignmentPolicyPairingRepository.GetAllAssignmentPolicyPairings();

            var userScopeClaims = await userScopeClaimRepository.GetAllUserScopeClaims();

            var accessPolicies = await accessPolicyRepository.GetAllAccessPolicies();

            var accesssPolicyPairings = await accessPolicyPairingRepository.GetAllAccessPoliciesPairings();

            var listings = await traditionalListingSearchRepository.GetAllListings();

            var collaborationListings = await traditionalListingSearchRepository.GetAllCollaborationListings();

            var relationshipListings = await traditionalListingSearchRepository.GetAllRelationshipListings();

            var teamListings = await traditionalListingSearchRepository.GetAllTeamListings();

            if (resources != null)
            {
                await DeleteAllFromTable("Resource");
                await ReseedAsync("Resource", 0, connectionString, dataGateway);
            }

            if (claimRepository != null)
            {
                await DeleteAllFromTable("Claim");
                await ReseedAsync("Claim", 0, connectionString, dataGateway);
            }

            if (scopeRepository != null)
            {
                await DeleteAllFromTable("Scope");
                await ReseedAsync("Scope", 0, connectionString, dataGateway);
            }

            if (scopeClaims != null)
            {
                await DeleteAllFromTable("ScopeClaim");
                await ReseedAsync("ScopeClaim", 0, connectionString, dataGateway);
            }
            if (assignmentPolicies != null)
            {
                await DeleteAllFromTable("AssignmentPolicy");
                await ReseedAsync("AssignmentPolicy", 0, connectionString, dataGateway);
            }

            if (assignmentPolicyPairings != null)
            {
                await DeleteAllFromTable("AssignmentPolicyPairing");
            }

            if (userScopeClaims != null)
            {
                await DeleteAllFromTable("UserScopeClaim");
                await ReseedAsync("UserScopeClaim", 0, connectionString, dataGateway);
            }

            if (userScopes != null)
            {
                await DeleteAllFromTable("UserScope");
                await ReseedAsync("UserScope", 0, connectionString, dataGateway);
            }

            if (userClaims != null)
            {
                await DeleteAllFromTable("UserClaim");
                await ReseedAsync("UserClaim", 0, connectionString, dataGateway);
            }

            if (accessPolicies != null)
            {
                await DeleteAllFromTable("AccessPolicy");
                await ReseedAsync("AccessPolicy", 0, connectionString, dataGateway);
            }

            if (accesssPolicyPairings != null)
            {
                await DeleteAllFromTable("AccessPolicyPairing");
                await ReseedAsync("AssignmentPolicyPairing", 0, connectionString, dataGateway);
                await ReseedAsync("AccessPolicyPairing", 0, connectionString, dataGateway);
            }

            if (loginAttempts != null)
            {
                await DeleteAllFromTable("LoginAttempts");
                await ReseedAsync("LoginAttempts", 0, connectionString, dataGateway);
            }

            if (accounts != null)
            {
                await DeleteAllFromTable("UserProfile");
                await DeleteAllFromTable("UserAccountSettings");
                await DeleteAllFromTable("UserAccountCode");
                await DeleteAllFromTable("UserAccount");

                await ReseedAsync("UserAccount", 0, connectionString, dataGateway);
                await ReseedAsync("UserProfile", 0, connectionString, dataGateway);
                await ReseedAsync("UserAccountCode", 0, connectionString, dataGateway);
                await ReseedAsync("UserAccountSettings", 0, connectionString, dataGateway);
            }
            if (listings != null)
            {
                await DeleteAllFromTable("Listing");
                await ReseedAsync("Listing", 0, connectionString, dataGateway);
            }
            if (collaborationListings != null)
            {
                await DeleteAllFromTable("Collaboration");
                await ReseedAsync("Collaboration", 0, connectionString, dataGateway);
            }
            if (relationshipListings != null)
            {
                await DeleteAllFromTable("Relationship");
                await ReseedAsync("Relationship", 0, connectionString, dataGateway);
            }
            if (teamListings != null)
            {
                await DeleteAllFromTable("TeamModel");
                await ReseedAsync("TeamModel", 0, connectionString, dataGateway);
            }
        }