public void TestCreate()
        {
            var user = new PassOneUser(_service.GetNextIdValue(), TestUser2.FirstName, TestUser2.LastName,
                                       TestUser2.Username,
                                       TestUser2.Password, TestUser2.k, TestUser2.v);
            _service.Create(user);

            User actual;
            using (var db = new PassOneContext())
            {
                db.Database.Connection.Open();
                var query = from u in db.Users select u;
                actual = query.ToList().FirstOrDefault(user1 => user1.Id == user.Id);
            }
            Assert.IsNotNull(actual);

            using (var db = new PassOneContext())
            {
                db.Database.Connection.Open();
                var userQuery = from u in db.Users select u;
                var remove = userQuery.ToList().FirstOrDefault(user1 => user1.Id == user.Id);
                db.Users.Remove(remove);
                db.SaveChanges();
            }
        }
        public void TestDelete()
        {
            _service.Delete(ConvertToDomainObject(TestCredentials));
            using (var db = new PassOneContext())
            {
                var query = from u in db.Credentials select u;
                var actual = query.ToList().FirstOrDefault(creds => creds.Id == TestCredentials.Id);

                Assert.IsNull(actual);
            }
        }
        public void TestDelete()
        {
            using (var db = new PassOneContext())
            {
                db.Database.Connection.Open();
                var credsQuery = from c in db.Credentials select c;
                var creds = credsQuery.ToList().FirstOrDefault((creds1 => creds1.Id == TestCredentials.Id));
                db.Credentials.Remove(creds);
                db.SaveChanges();
                var user = new PassOneUser(TestUser.Id, TestUser.FirstName, TestUser.LastName, TestUser.Username,
                                           TestUser.Password, TestUser.k, TestUser.v);
                _service.Delete(user);

                var userQuery = from u in db.Users select u;
                var actual = userQuery.ToList().FirstOrDefault(user1 => user1.Id == user.Id);

                Assert.IsNull(actual);
            }
        }
        public void TestCreate()
        {
            var creds = ConvertToDomainObject(TestCredentials);
            _service.Create(creds);

            PassOneCredentials expected = creds;
            PassOneCredentials actual;
            using (var db = new PassOneContext())
            {
                db.Database.Connection.Open();
                var query = from u in db.Credentials select u;
                actual = ConvertToDomainObject(query.ToList().FirstOrDefault(creds1 => creds1.Id == creds.Id));
            }
            Assert.AreEqual(expected, actual);

            using (var db = new PassOneContext())
            {
                db.Database.Connection.Open();
                var credsQuery = from c in db.Credentials select c;
                var remove = credsQuery.ToList().FirstOrDefault(creds1 => creds1.Id == creds.Id);
                db.Credentials.Remove(remove);
                db.SaveChanges();
            }
        }
Пример #5
0
        public void Setup()
        {
            try
               {
               using (var db = new PassOneContext())
               {
                   db.Database.Connection.Open();
                   TestCredentials.UserId = TestUser.Id;
                   TestUser.Credentials.Add(TestCredentials);
                   db.Users.Add(TestUser);
                   db.Credentials.Add(TestCredentials);
                   db.SaveChanges();
               }
               }
               catch (DbEntityValidationException e)
               {
               foreach (var eve in e.EntityValidationErrors)
               {
                   System.Diagnostics.Debug.WriteLine(
                       "Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                       eve.Entry.Entity.GetType().Name, eve.Entry.State);
                   foreach (var ve in eve.ValidationErrors)
                   {
                       System.Diagnostics.Debug.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                                          ve.PropertyName, ve.ErrorMessage);
                   }
               }
               }
               catch (Exception)
               {

               }
        }
Пример #6
0
        public void TearDown()
        {
            using (var db = new PassOneContext())
               {
                   try
                   {
                       db.Database.Connection.Open();
                       var credsQuery = from c in db.Credentials select c;
                       var creds = credsQuery.ToList().FirstOrDefault((creds1 => creds1.Id == TestCredentials.Id));
                       db.Credentials.Remove(creds);
                       db.SaveChanges();
                   }
                   catch
                   {

                   }
                   try
                   {
                       var userQuery = from u in db.Users select u;
                       var user = userQuery.ToList().FirstOrDefault(user1 => user1.Id == TestUser.Id);
                       db.Users.Remove(user);
                       db.SaveChanges();
                   }
                   catch
                   {
                   }
               }

               TestUser.Credentials = null;
               TestCredentials.UserId = 0;
        }