Beispiel #1
0
        public void UpdateNoDBHaspKey()
        {
            var keyNoDB = new HaspKey
            {
                Id      = 234,
                InnerId = 1546,
                Number  = "uz-265",
                IsHome  = false,
                TypeKey = TypeKey.NetTime,
            };

            using (var db = new EntitesContext())
            {
                ClearTable.HaspKeys(db);
                haspKeyDAO = new DbHaspKeyDAO(db);
                haspKeyDAO.Add(CreateNew());
                Assert.IsFalse(haspKeyDAO.Update(keyNoDB));
            }
        }
Beispiel #2
0
        public void GetAllHaspKey()
        {
            var getAll   = new List <HaspKey>();;
            var haspKeys = CreateListEntities.HaspKeys();

            using (var db = new EntitesContext())
            {
                ClearTable.HaspKeys(db);
                haspKeyDAO = new DbHaspKeyDAO(db);

                foreach (var key in haspKeys)
                {
                    haspKeyDAO.Add(key);
                }

                getAll = haspKeyDAO.GetAll();
            }

            CollectionAssert.AreEqual(getAll, haspKeys);
        }
Beispiel #3
0
        public void RemoveHaspKey()
        {
            bool remove;

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

                haspKeyDAO = new DbHaspKeyDAO(db);
                db.HaspKeys.AddRange(CreateListEntities.HaspKeys());
                db.KeyFeatures.AddRange(CreateListEntities.KeyFeatures());
                db.KeyFeatureClients.AddRange(CreateListEntities.KeyFeatureClients());
                db.SaveChanges();

                remove = haspKeyDAO.Remove(1);
            }

            Assert.IsTrue(remove);
        }
Beispiel #4
0
        public void UpdateHaspKey()
        {
            bool update;

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

                haspKeyDAO = new DbHaspKeyDAO(db);
                haspKeyDAO.Add(CreateNew());
                update = haspKeyDAO.Update(new HaspKey
                {
                    Id      = 1,
                    InnerId = 23,
                    Number  = "u2322",
                    IsHome  = false,
                    TypeKey = TypeKey.Time,
                });
            }

            Assert.IsTrue(update);
        }
Beispiel #5
0
        public void GetByActiveHaspKey()
        {
            List <HaspKey> GetByActive;
            var            GetByActiveExpected = new List <HaspKey>
            {
                CreateNew(1),
            };

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

                haspKeyDAO = new DbHaspKeyDAO(db);

                db.HaspKeys.AddRange(CreateListEntities.HaspKeys());
                db.KeyFeatures.AddRange(CreateListEntities.KeyFeatures());
                db.SaveChanges();

                GetByActive = haspKeyDAO.GetByActive();
            }

            CollectionAssert.AreEqual(GetByActive, GetByActiveExpected);
        }
Beispiel #6
0
 public void NullEntitesContextHaspKey()
 {
     Assert.ThrowsException <ArgumentNullException>(() => haspKeyDAO = new DbHaspKeyDAO(null));
 }
Beispiel #7
0
 public HaspKeyLogic(IContractHaspKeyDAO haspKeyDAO)
 {
     this.haspKeyDAO = haspKeyDAO ?? throw new ArgumentNullException(nameof(haspKeyDAO));
 }