BetterMembership.Web.BetterProfileProvider.FindProfilesByUserName C# (CSharp) Метод

FindProfilesByUserName() публичный Метод

public FindProfilesByUserName ( ProfileAuthenticationOption authenticationOption, string usernameToMatch, int pageIndex, int pageSize, int &totalRecords ) : System.Web.Profile.ProfileInfoCollection
authenticationOption ProfileAuthenticationOption
usernameToMatch string
pageIndex int
pageSize int
totalRecords int
Результат System.Web.Profile.ProfileInfoCollection
        public override ProfileInfoCollection FindProfilesByUserName(
            ProfileAuthenticationOption authenticationOption, 
            string usernameToMatch, 
            int pageIndex, 
            int pageSize, 
            out int totalRecords)
        {
            Condition.Requires(usernameToMatch, "usernameToMatch").IsNotNullOrWhiteSpace();
            Condition.Requires(pageIndex, "pageIndex").IsGreaterOrEqual(0);
            Condition.Requires(pageSize, "pageSize").IsGreaterOrEqual(1);

            if (authenticationOption != ProfileAuthenticationOption.All)
            {
                throw new NotSupportedException("only ProfileAuthenticationOption.All is supported");
            }

            var startRow = GetPagingStartRow(pageIndex, pageSize);

            using (var db = this.ConnectToDatabase())
            {
                usernameToMatch = AppendWildcardToSearchTerm(usernameToMatch);
                var rows = db.Query(this.sqlQueryBuilder.FindUsersByName, startRow, pageSize, usernameToMatch).ToList();
                return ExtractProfileInfoFromRows(rows, out totalRecords);
            }
        }

Usage Example

        public void GivenConfirmedUsersWhenFindUsersbyUserNameThenThrowNotSupportedException(
            ProfileAuthenticationOption option)
        {
            // arrange
            var testClass = new BetterProfileProvider();

            // act // assert
            int totalRecords1;
            Assert.Throws<NotSupportedException>(
                () => testClass.FindProfilesByUserName(option, "value", 0, 10, out totalRecords1));
        }