/// <summary>
        /// Process Request to create user based on HTTP context
        /// </summary>
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest request = context.Request;
            HttpResponse response = context.Response;
            String jsonString = String.Empty;
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            LoginModel.Login login = new LoginModel.Login(new User { 
                UserName = request.Form["userName"],
                Password = request.Form["password"],
                FirstName = request.Form["firstName"],
                LastName = request.Form["lastName"],
                Email = request.Form["email"]
            });

            MembershipCreateStatus createStatus = login.CreateUser(new WebContentLocator());
            jsonString = serializer.Serialize(new { result = createStatus.ToString() });

            response.Write(jsonString);
            response.ContentType = "application/json";
        }
        public void TestCreateUser()
        {
            String userName = Convert.ToString(TestContext.DataRow["UserName"]);
            String password = Convert.ToString(TestContext.DataRow["Password"]);
            String firstName = Convert.ToString(TestContext.DataRow["FirstName"]);
            String lastName = Convert.ToString(TestContext.DataRow["LastName"]);
            String email = Convert.ToString(TestContext.DataRow["Email"]);
            String expectedResult = Convert.ToString(TestContext.DataRow["Result"]);

            IUser newUser = new User
            {
                UserName = userName,
                Password = password,
                FirstName = firstName,
                LastName = lastName,
                Email = email
            };
            LoginModel.Login login = new LoginModel.Login(newUser);
            String actualResult = login.CreateUser(new TestContentLocator()).ToString();

            Assert.AreEqual(expectedResult, actualResult);
        }
Example #3
0
        /// <summary>
        /// Process Request to create user based on HTTP context
        /// </summary>
        public void ProcessRequest(HttpContext context)
        {
            HttpRequest          request    = context.Request;
            HttpResponse         response   = context.Response;
            String               jsonString = String.Empty;
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            LoginModel.Login login = new LoginModel.Login(new User {
                UserName  = request.Form["userName"],
                Password  = request.Form["password"],
                FirstName = request.Form["firstName"],
                LastName  = request.Form["lastName"],
                Email     = request.Form["email"]
            });

            MembershipCreateStatus createStatus = login.CreateUser(new WebContentLocator());

            jsonString = serializer.Serialize(new { result = createStatus.ToString() });

            response.Write(jsonString);
            response.ContentType = "application/json";
        }
        public void TestCreateUser()
        {
            String userName       = Convert.ToString(TestContext.DataRow["UserName"]);
            String password       = Convert.ToString(TestContext.DataRow["Password"]);
            String firstName      = Convert.ToString(TestContext.DataRow["FirstName"]);
            String lastName       = Convert.ToString(TestContext.DataRow["LastName"]);
            String email          = Convert.ToString(TestContext.DataRow["Email"]);
            String expectedResult = Convert.ToString(TestContext.DataRow["Result"]);

            IUser newUser = new User
            {
                UserName  = userName,
                Password  = password,
                FirstName = firstName,
                LastName  = lastName,
                Email     = email
            };

            LoginModel.Login login        = new LoginModel.Login(newUser);
            String           actualResult = login.CreateUser(new TestContentLocator()).ToString();

            Assert.AreEqual(expectedResult, actualResult);
        }