public void createDelete()
        {
            var newMiniUser = new MiniUser {
                email    = "*****@*****.**",
                password = "******"
            };

            newMiniUser = MiniUsers.Create(newMiniUser).Result;
            string id = newMiniUser.id;

            Assert.AreEqual("*****@*****.**", newMiniUser.email);
            //trying to create duplicate MiniUser
            try
            {
                MiniUser usr = MiniUsers.Create(newMiniUser).Result;
                Assert.Fail();
            }
            catch (AggregateException e)
            {
                var restException = (RestException)e.InnerException;
                Assert.AreEqual(422, restException.StatusCode);
            }
            MiniUsers.DeleteById(id).Wait();
            try
            {
                MiniUser delRes = MiniUsers.FindById(id).Result;
                Assert.Fail();
            }
            catch (AggregateException e)
            {
                var restException = (RestException)e.InnerException;
                Assert.AreEqual(404, restException.StatusCode);
            }
        }
        public void create()
        {
            var newMiniUser = new MiniUser {
                email    = "*****@*****.**",
                password = "******"
            };

            newMiniUser = MiniUsers.Create(newMiniUser).Result;
            string id = newMiniUser.id;

            Assert.AreEqual("*****@*****.**", newMiniUser.email);
            //trying to create duplicate MiniUser
            try
            {
                newMiniUser = MiniUsers.Create(newMiniUser).Result;
                Assert.Fail();
            }
            catch (AggregateException e)
            {
                var restException = (RestException)e.InnerException;
                Assert.AreEqual(422, restException.StatusCode);
            }
            performLoginAsAdmin();
            MiniUsers.DeleteById(id).Wait();
            MiniUsers.logout().Wait();
        }
Exemplo n.º 3
0
    public OnlineSkiPass(string code)
    {
        cardCode = code;
        DataTable dtOrder = DBHelper.GetDataTable(" select [id] from order_online where type='雪票' and code = '" + code.Trim() + "' ");

        associateOnlineOrder       = new OnlineOrder(int.Parse(dtOrder.Rows[0][0].ToString()));
        associateOnlineOrderDetail = associateOnlineOrder.OrderDetails[0];
        productName   = associateOnlineOrderDetail.productName.Trim();
        count         = associateOnlineOrderDetail.count;
        associateCard = new Card(code);

        owner = new MiniUsers(associateOnlineOrder._fields["open_id"].ToString());

        if (associateCard._fields["type"].Equals("雪票"))
        {
            if (!associateCard._fields["used"].ToString().Equals("0"))
            {
                used = true;
                try
                {
                    useDate = DateTime.Parse(associateCard._fields["use_date"].ToString());
                }
                catch
                {
                }
            }
        }
    }
Exemplo n.º 4
0
        public void login()
        {
            var credentials = new MiniUser {
                email    = "*****@*****.**",
                password = "******"
            };
            var accessToken = MiniUsers.login(credentials).Result;

            Assert.AreEqual("1", accessToken.Property("userId").Value.ToString());
        }
Exemplo n.º 5
0
        /*	perfomLogin
         * preforms login as admin
         */

        public void performLogin()
        {
            var credentials = new MiniUser {
                email    = "*****@*****.**",
                password = "******"
            };
            var a = MiniUsers.login(credentials).Result;

            Gateway.SetAccessToken(a);
        }
        public void findOne()
        {
            MiniUser usr = MiniUsers.FindOne().Result;

            Assert.AreNotEqual(null, usr);
            Assert.AreEqual("1", usr.getID());

            usr = MiniUsers.FindOne("{\"where\": {\"email\" : \"[email protected]\"}}").Result;
            Assert.AreNotEqual(null, usr);
            Assert.AreEqual("2", usr.getID());
        }
        public void a13_find()
        {
            IList <MiniUser> usrList = MiniUsers.Find().Result;

            Assert.AreNotEqual(null, usrList);
            int i = 1;

            foreach (MiniUser usr in usrList)
            {
                Assert.AreEqual(i.ToString(), usr.getID());
                i++;
            }
        }
Exemplo n.º 8
0
 public void count()
 {
     try
     {
         int result = MiniUsers.Count().Result;
         Assert.Fail();
     }
     catch (AggregateException e)
     {
         var restException = (RestException)e.InnerException;
         Assert.AreEqual(401, restException.StatusCode);
     }
 }
Exemplo n.º 9
0
 public void deleteById()
 {
     try
     {
         MiniUsers.DeleteById("3").Wait();
         Assert.Fail();
     }
     catch (AggregateException e)
     {
         var restException = (RestException)e.InnerException;
         Assert.AreEqual(401, restException.StatusCode);
     }
 }
Exemplo n.º 10
0
 public void find()
 {
     try
     {
         IList <MiniUser> usrList = MiniUsers.Find().Result;
         Assert.Fail();
     }
     catch (AggregateException e)
     {
         var restException = (RestException)e.InnerException;
         Assert.AreEqual(401, restException.StatusCode);
     }
 }
 public void exists()
 {
     try
     {
         bool result = MiniUsers.Exists("1").Result;
         Assert.Fail();
     }
     catch (AggregateException e)
     {
         var restException = (RestException)e.InnerException;
         Assert.AreEqual(401, restException.StatusCode);
     }
 }
        public void findById()
        {
            var usr = new MiniUser {
                email    = "*****@*****.**",
                password = "******"
            };

            usr = MiniUsers.Create(usr).Result;
            usr = MiniUsers.FindById(usr.id).Result;
            Assert.AreNotEqual(null, usr);
            Assert.AreEqual("*****@*****.**", usr.email);
            MiniUsers.DeleteById(usr.id).Wait();
        }
Exemplo n.º 13
0
        public void updateAll()
        {
            var upUsr = new MiniUser {
                email = "*****@*****.**"
            };

            try
            {
                MiniUsers.UpdateAll(upUsr, "{\"id\" : \"3\"}").Wait();
                Assert.Fail();
            }
            catch (AggregateException e)
            {
                var restException = (RestException)e.InnerException;
                Assert.AreEqual(401, restException.StatusCode);
            }
        }
        public void updateAll_ById()
        {
            var upUsr = new MiniUser {
                email = "*****@*****.**"
            };
            var    newIds = new List <string> ();
            string filter = "{\"or\": [";

            for (int i = 0; i < 4; i++)
            {
                var newMiniUser = new MiniUser {
                    email    = "newMiniUserA" + i + "@g.com",
                    password = "******"
                };
                newMiniUser = MiniUsers.Create(newMiniUser).Result;
                newIds.Add(newMiniUser.id);
                filter = filter + "{\"id\": \"" + newMiniUser.id + "\"}";
                if (i < 3)
                {
                    filter = filter + " ,";
                }
            }
            filter = filter + "]}";

            MiniUsers.UpdateAll(upUsr, filter).Wait();
            MiniUser upRes;

            foreach (string id in newIds)
            {
                upRes = MiniUsers.FindById(id).Result;
                Assert.AreEqual(upUsr.email, upRes.email);
            }

            upUsr = new MiniUser {
                email = "*****@*****.**"
            };
            MiniUsers.UpdateById(newIds[0], upUsr).Wait();

            upRes = MiniUsers.FindById(newIds[0]).Result;
            Assert.AreEqual(upUsr.email, upRes.email);
            foreach (string id in newIds)
            {
                MiniUsers.DeleteById(id);
            }
        }
Exemplo n.º 15
0
        public void findById()
        {
            MiniUser usr = MiniUsers.FindById("2").Result;

            Assert.AreNotEqual(null, usr);
            Assert.AreEqual("*****@*****.**", usr.email);

            try
            {
                usr = MiniUsers.FindById("1").Result;
                Assert.Fail();
            }
            catch (AggregateException e)
            {
                var restException = (RestException)e.InnerException;
                Assert.AreEqual(401, restException.StatusCode);
            }
        }
Exemplo n.º 16
0
        public void updateById()
        {
            var upUsr = new MiniUser {
                email = "*****@*****.**"
            };

            //update self
            MiniUsers.UpdateById("2", upUsr).Wait();
            //trying to update other
            try
            {
                MiniUsers.UpdateById("3", upUsr).Wait();
                Assert.Fail();
            }
            catch (AggregateException e)
            {
                var restException = (RestException)e.InnerException;
                Assert.AreEqual(401, restException.StatusCode);
            }
            MiniUser upRes = MiniUsers.FindById("2").Result;

            Assert.AreEqual(upUsr.email, upRes.email);

            //perform update checks using admin login
            performLoginAsAdmin();

            upRes = MiniUsers.FindById("3").Result;
            Assert.AreNotEqual(upUsr.email, upRes.email);

            upUsr = new MiniUser {
                email = "*****@*****.**"
            };

            //update back to original state
            MiniUsers.UpdateById("2", upUsr).Wait();
            performLogin();
        }
Exemplo n.º 17
0
 public void teardown()
 {
     MiniUsers.logout().Wait();
 }
 public void exists()
 {
     Assert.AreEqual(true, MiniUsers.Exists("1").Result);
     Assert.AreEqual(false, MiniUsers.Exists("10").Result);
 }
Exemplo n.º 19
0
    public int Place(string openId)
    {
        if (_fields == null)
        {
            MiniUsers user = new MiniUsers(openId.Trim());
            if (user != null)
            {
                string name = "小程序用户";
                try
                {
                    MiniUsers miniUser = new MiniUsers(openId.Trim());
                    if (!miniUser._fields["nick"].ToString().Trim().Equals(""))
                    {
                        name = miniUser._fields["nick"].ToString().Trim();
                    }
                    if (!miniUser._fields["real_name"].ToString().Trim().Equals(""))
                    {
                        name = miniUser._fields["real_name"].ToString().Trim();
                    }
                }
                catch
                {
                }
                string[,] insertParam = { { "type",                 "varchar", Type.Trim()                                   },
                                          { "open_id",              "varchar", openId.Trim()                                 },
                                          { "cell_number",          "varchar", user._fields["cell_number"].ToString().Trim() },
                                          { "name",                 "varchar", name.Trim()                                   },
                                          { "pay_method",           "varchar", PayMethod.Trim()                              },
                                          { "order_price",          "float",   OrderPrice.ToString()                         },
                                          { "order_real_pay_price", "float",   OrderPrice.ToString()                         },
                                          { "shop",                 "varchar", shop.Trim()                                   },
                                          { "memo",                 "varchar", memo.Trim()                                   } };
                int i = DBHelper.InsertData("order_online", insertParam);

                if (i == 1)
                {
                    int       totalScore = 0;
                    DataTable dt         = DBHelper.GetDataTable(" select top 1 *  from order_online order by [id] desc");
                    int       maxId      = int.Parse(dt.Rows[0][0].ToString());
                    _fields = dt.Rows[0];

                    foreach (OnlineOrderDetail detail in orderDetails)
                    {
                        detail.AddNew(maxId);
                        if (detail.productId > 0)
                        {
                            Product p = new Product(detail.productId);
                            totalScore = totalScore + int.Parse(p._fields["award_score"].ToString().Trim());
                        }
                    }
                    DBHelper.UpdateData("order_online", new string[, ] {
                        { "generate_score", "int", totalScore.ToString() }
                    },
                                        new string[, ] {
                        { "id", "int", maxId.ToString() }
                    }, Util.conStr.Trim());
                    return(maxId);
                }
            }
        }
        return(0);
    }
 public void count()
 {
     Assert.AreEqual(3, MiniUsers.Count().Result);
 }