示例#1
0
 public void GetByErroneousNumberKeyClient()
 {
     using (var db = new EntitesContext())
     {
         clientDAO = new DbClientDAO(db);
         Assert.ThrowsException <ArgumentException>(() => clientDAO.GetByNumberKey(erroneousId));
     }
 }
示例#2
0
        public Client GetByNumberKey(int keyInnerId)
        {
            if (keyInnerId < 1)
            {
                throw new ArgumentException(nameof(keyInnerId));
            }

            return(clientDAO.GetByNumberKey(keyInnerId));
        }
示例#3
0
 public void GetByNumberKeyNoDBClient()
 {
     using (var db = new EntitesContext())
     {
         ClearTable.HaspKeys(db);
         clientDAO = new DbClientDAO(db);
         Assert.IsNull(clientDAO.GetByNumberKey(2));
     }
 }
示例#4
0
        public void GetByNumberKeyClient()
        {
            Client getByNumberKey;
            Client actual = CreateListEntities.Clients()[0];

            using (var db = new EntitesContext())
            {
                ClearTable.HaspKeys(db);
                ClearTable.KeyFeatures(db);
                ClearTable.Clients(db);
                ClearTable.KeyFeatureClients(db);

                clientDAO = new DbClientDAO(db);
                db.HaspKeys.AddRange(CreateListEntities.HaspKeys());
                db.KeyFeatures.AddRange(CreateListEntities.KeyFeatures());
                db.Clients.AddRange(CreateListEntities.Clients());
                db.KeyFeatureClients.AddRange(CreateListEntities.KeyFeatureClients());
                db.SaveChanges();

                getByNumberKey = clientDAO.GetByNumberKey(1);
            }

            Assert.AreEqual(getByNumberKey, actual);
        }