コード例 #1
0
        public void CanConvertTo_is_TRUE_for_converting_MembershipUserCollection_to_IEnumerableMembershipUser()
        {
            //arrange
            var converter = new EnumerableToEnumerableTConverter <MembershipUserCollection, MembershipUser>();

            //act
            var result = converter.CanConvertTo(typeof(IEnumerable <MembershipUser>));

            //assert
            Assert.True(result);
        }
		public void CanConvertTo_is_TRUE_for_converting_MembershipUserCollection_to_IEnumerableMembershipUser()
		{
			//arrange
			var converter = new EnumerableToEnumerableTConverter<MembershipUserCollection, MembershipUser>();

			//act
			var result = converter.CanConvertTo( typeof(IEnumerable<MembershipUser>) );

			//assert
			Assert.True( result );
		}
コード例 #3
0
        public IPagedList<MembershipUser> FindByEmail(string emailAddressToMatch, int pageNumber, int pageSize)
		{
			// get one page of users
			int totalUserCount;
            var usersCollection = _membershipProvider.FindUsersByEmail(emailAddressToMatch, pageNumber - 1, pageSize, out totalUserCount);

			// convert from MembershipUserColletion to PagedList<MembershipUser> and return
			var converter = new EnumerableToEnumerableTConverter<MembershipUserCollection, MembershipUser>();
			var usersList = converter.ConvertTo<IEnumerable<MembershipUser>>(usersCollection);
            var usersPagedList = new StaticPagedList<MembershipUser>(usersList, pageNumber, pageSize, totalUserCount);
			return usersPagedList;
		}
コード例 #4
0
        public IPagedList<MembershipUser> FindAll(int pageIndex, int pageSize)
        {
            // get one page of users
            int totalUserCount;
            var usersCollection = _membershipProvider.GetAllUsers(pageIndex, pageSize, out totalUserCount);

            // convert from MembershipUserColletion to PagedList<MembershipUser> and return
            var converter = new EnumerableToEnumerableTConverter<MembershipUserCollection, MembershipUser>();
            var usersList = converter.ConvertTo<IEnumerable<MembershipUser>>(usersCollection);
            var usersPagedList = new StaticPagedList<MembershipUser>(usersList, pageIndex, pageSize, totalUserCount);
            return usersPagedList;
        }
		public void ConvertTo_returns_IEnumerableMembershipUser_with_all_MembershipUser_items_from_passed_MembershipUserCollection()
		{
			//arrange
			var converter = new EnumerableToEnumerableTConverter<MembershipUserCollection, MembershipUser>();
			var user1 = new MembershipUser( "AspNetSqlMembershipProvider", "User1", null, "*****@*****.**", "Question", "Comment", true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now );
			var user2 = new MembershipUser( "AspNetSqlMembershipProvider", "User2", null, "*****@*****.**", "Question", "Comment", true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now );

			//act
			var result = converter.ConvertTo(new MembershipUserCollection { user1, user2 }, typeof(IEnumerable<MembershipUser>));

			//assert
			var users = Assert.IsAssignableFrom<IEnumerable<MembershipUser>>( result );
			Assert.Contains( user1, users );
			Assert.Contains( user2, users );
		}
コード例 #6
0
        public void ConvertTo_returns_IEnumerableMembershipUser_with_all_MembershipUser_items_from_passed_MembershipUserCollection()
        {
            //arrange
            var converter = new EnumerableToEnumerableTConverter <MembershipUserCollection, MembershipUser>();
            var user1     = new MembershipUser("AspNetSqlMembershipProvider", "User1", null, "*****@*****.**", "Question", "Comment", true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now);
            var user2     = new MembershipUser("AspNetSqlMembershipProvider", "User2", null, "*****@*****.**", "Question", "Comment", true, false, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now, DateTime.Now);

            //act
            var result = converter.ConvertTo(new MembershipUserCollection {
                user1, user2
            }, typeof(IEnumerable <MembershipUser>));

            //assert
            var users = Assert.IsAssignableFrom <IEnumerable <MembershipUser> >(result);

            Assert.Contains(user1, users);
            Assert.Contains(user2, users);
        }