|
/****************************************************************************************************
Copyright (C) 2010 RapidWebDev Organization (http://rapidwebdev.org)
Author: Tim, Legal Name: Long Yi, Email: tim.long.yi@RapidWebDev.org
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RapidWebDev.UI.DynamicPages;
using RapidWebDev.Platform.Web.DynamicPage;
using RapidWebDev.Mocks.UIMocks;
using RapidWebDev.Mocks;
using RapidWebDev.UI.Services;
using RapidWebDev.Platform.Linq;
using RapidWebDev.Platform;
using RapidWebDev.Common;
using RapidWebDev.Common.Data;
using RapidWebDev.UI.DynamicPages.Configurations;
using NUnit.Framework;
using System.Web.UI;
using RapidWebDev.Platform.Initialization;
namespace RapidWebDev.Tests.DynamicPage
{
[TestFixture]
public class UserManagementTest
{
private List<Guid> createdObjectIds = new List<Guid>();
[TearDown]
public void TearDown()
{
using (MembershipDataContext ctx = DataContextFactory.Create<MembershipDataContext>())
{
foreach (Guid createdObjectId in createdObjectIds)
{
ctx.Memberships.Delete(m => m.UserId == createdObjectId);
ctx.Users.Delete(u => u.UserId == createdObjectId);
ctx.SubmitChanges();
}
}
createdObjectIds.Clear();
}
[Test]
public void TestQuery()
{
UserManagement page = new UserManagement();
DynamicPageProxy proxy = new DynamicPageProxy(page);
IMembershipApi membershipApi = SpringContext.Current.GetObject<IMembershipApi>();
IPlatformConfiguration platformConfiguration = SpringContext.Current.GetObject<IPlatformConfiguration>();
using (var httpEnv = new HttpEnvironment())
{
httpEnv.SetRequestUrl(@"/UserManagement/DynamicPage.svc?Domain=Department");
#region Create Data
Guid guid = Guid.NewGuid();
string surfix = guid.ToString().Substring(0, 5);
UserObject obj = new UserObject()
{
OrganizationId = platformConfiguration.Organization.OrganizationId,
Comment = "IT specialist",
DisplayName = "Eunge Liu" + surfix,
Email = "eunge.liu@gmail.com",
IsApproved = true,
MobilePin = "137641855XX",
UserName = "Eunge"+surfix
};
membershipApi.Save(obj, "password1", null);
createdObjectIds.Add(obj.UserId);
#endregion
#region query
QueryParameterExpression expression = new QueryParameterExpression("UserName", QueryFieldOperators.Equal, "Eunge" + surfix);
SortExpression sort = new SortExpression("UserName");
QueryParameter parameters = new QueryParameter()
{
//Expressions = express,
PageIndex = 0,
PageSize = 10,
SortExpression = sort
};
parameters.Expressions.Add(expression);
QueryResults results = proxy.Query(parameters);
foreach (var result in results.Results)
{
Assert.AreEqual(DataBinder.Eval(result, "UserName"), "Eunge" + surfix);
}
#endregion
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I've worked as a software architect and developer based on Microsoft .NET framework and web technology since 2002, having rich experience on SaaS, multiple-tier web system and website development. I've devoted into open source project development since 2003, and have created 3 main projects including DataQuicker (ORM), ExcelQuicker (Excel Report Generator), and RapidWebDev (Enterprise-level CMS)
I worked in BenQ (8 mo), Bleum (4 mo), Newegg (1 mo), Microsoft (3 yr) and Autodesk (5 yr) before 2012. Now I own a startup company in Shanghai China to deliver the exceptional results to global internet users by leveraging the power of Internet and the local excellence.