Exemple #1
0
        public void AddUserTest()
        {
            MsSqlFactory      factory  = new MsSqlFactory(Common.Connectionconfig);
            MsSqlDataProvider provider = factory.CreateDBProvider() as MsSqlDataProvider;

            using (DbContext context = provider.GenerateContext())
            {
                SignUpModel model = new SignUpModel()
                {
                    Login    = "******",
                    Password = "******",
                    EMail    = "*****@*****.**"
                };
                try
                {
                    Assert.IsTrue(provider.AddUser(model) > 0, "User not saved without error.");

                    Assert.IsTrue(provider.CheckUserCredentials(model.Login, model.Password), "Wrong user saved (login)");
                    Assert.IsTrue(provider.CheckUserCredentials(model.EMail, model.Password), "Wrong user saved (email)");


                    DragonflyEntities ents = context as DragonflyEntities;
                    if (ents != null)
                    {
                        User foundUser = (from u in ents.User
                                          where u.Login.Equals(model.Login)
                                          select u).FirstOrDefault();
                        if (foundUser != null)
                        {
                            Assert.AreEqual(model.EMail, foundUser.E_mail, "Wrong e-mail saved.");
                            //TODO check stored password
                        }
                    }
                }
                finally
                {
                    DeleteUserFromDB(context, model.Login, model.EMail);
                    //TODO delete test user
                }
            }
        }