BetterMembership.Web.BetterProfileProvider.GetAllProfiles C# (CSharp) Method

GetAllProfiles() public method

public GetAllProfiles ( ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, int &totalRecords ) : System.Web.Profile.ProfileInfoCollection
authenticationOption ProfileAuthenticationOption
pageIndex int
pageSize int
totalRecords int
return System.Web.Profile.ProfileInfoCollection
        public override ProfileInfoCollection GetAllProfiles(
            ProfileAuthenticationOption authenticationOption, int pageIndex, int pageSize, out int totalRecords)
        {
            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())
            {
                var rows = db.Query(this.sqlQueryBuilder.GetAllUsers, startRow, pageSize).ToList();
                return ExtractProfileInfoFromRows(rows, out totalRecords);
            }
        }

Usage Example

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

            // act // assert
            int totalRecords;
            Assert.Throws<NotSupportedException>(
                () => testClass.GetAllProfiles(option, 0, 10, out totalRecords));
        }