예제 #1
0
 public void AddNullKeyFeature()
 {
     using (var db = new EntitesContext())
     {
         kfDAO = new DbKeyFeatureDAO(db);
         Assert.ThrowsException <ArgumentNullException>(() => kfDAO.Add(null));
     }
 }
예제 #2
0
 public void RemoveNoDBKeyFeature()
 {
     using (var db = new EntitesContext())
     {
         ClearTable.KeyFeatures(db);
         kfDAO = new DbKeyFeatureDAO(db);
         kfDAO.Add(CreateNew());
         Assert.IsFalse(kfDAO.Remove(123));
     }
 }
예제 #3
0
        public void ContainsDBKeyFeature()
        {
            var keyFeat = CreateNew();

            using (var db = new EntitesContext())
            {
                ClearTable.KeyFeatures(db);
                kfDAO = new DbKeyFeatureDAO(db);
                kfDAO.Add(keyFeat);
                Assert.IsTrue(kfDAO.ContainsDB(keyFeat));
            }
        }
예제 #4
0
        public void AddKeyFeature()
        {
            int idExpected = 1;
            int add;

            using (var db = new EntitesContext())
            {
                ClearTable.KeyFeatures(db);
                kfDAO = new DbKeyFeatureDAO(db);
                add   = kfDAO.Add(CreateNew());
            }
            Assert.AreEqual(add, idExpected);
        }
예제 #5
0
        public void GetByIdKeyFeature()
        {
            KeyFeature getById;
            KeyFeature kfExpected = CreateNew(1);

            using (var db = new EntitesContext())
            {
                ClearTable.KeyFeatures(db);
                kfDAO = new DbKeyFeatureDAO(db);
                kfDAO.Add(CreateNew());
                getById = kfDAO.GetById(1);
            }

            Assert.AreEqual(getById, kfExpected);
        }
예제 #6
0
        public void UpdateNoDBKeyFeature()
        {
            var kfNoDB = new KeyFeature
            {
                Id        = 32,
                IdFeature = 3,
                IdHaspKey = 24,
                EndDate   = date.AddDays(100),
                StartDate = date,
            };

            using (var db = new EntitesContext())
            {
                ClearTable.KeyFeatures(db);
                kfDAO = new DbKeyFeatureDAO(db);
                kfDAO.Add(CreateNew());
                Assert.IsFalse(kfDAO.Update(kfNoDB));
            }
        }
예제 #7
0
        public void GetAllKeyFeature()
        {
            var getAll   = new List <KeyFeature>();
            var keyFeats = CreateListEntities.KeyFeatures();

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

                foreach (var kf in keyFeats)
                {
                    kfDAO.Add(kf);
                }

                getAll = kfDAO.GetAll();
            }

            CollectionAssert.AreEqual(getAll, keyFeats);
        }
예제 #8
0
        public void UpdateKeyFeature()
        {
            bool update;

            using (var db = new EntitesContext())
            {
                ClearTable.KeyFeatures(db);
                kfDAO = new DbKeyFeatureDAO(db);
                kfDAO.Add(CreateNew());

                update = kfDAO.Update(new KeyFeature
                {
                    Id        = 1,
                    IdFeature = 2,
                    IdHaspKey = 3,
                    StartDate = date.AddDays(5),
                    EndDate   = date.AddDays(10),
                });
            }

            Assert.IsTrue(update);
        }
예제 #9
0
        public bool Save(KeyFeature entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            CheckArgument(entity);

            int id;

            if (!keyFeatureDAO.ContainsDB(entity))
            {
                id = keyFeatureDAO.Add(entity);
            }
            else
            {
                return(false);
            }

            return(id > 0);
        }