Beispiel #1
0
        public void SaveDuplicateKeyFeature()
        {
            bool add;

            using (var db = new EntitesContext())
            {
                ClearTable.KeyFeatures(db);
                keyFeatureL = Get(db);
                keyFeatureL.Save(CreateNew());
                add = keyFeatureL.Save(CreateNew());
            }
            Assert.IsFalse(add);
        }
Beispiel #2
0
 public void SaveNullKeyFeature()
 {
     using (var db = new EntitesContext())
     {
         keyFeatureL = Get(db);
         Assert.ThrowsException <ArgumentNullException>(() => keyFeatureL.Save(null));
     }
 }
Beispiel #3
0
 public void RemoveNoDBKeyFeature()
 {
     using (var db = new EntitesContext())
     {
         ClearTable.KeyFeatures(db);
         keyFeatureL = Get(db);
         keyFeatureL.Save(CreateNew());
         Assert.IsFalse(keyFeatureL.Remove(123));
     }
 }
Beispiel #4
0
        public void ErroneousArgumentSaveKeyFeature()
        {
            KeyFeature keyFeature = CreateNew();

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

                keyFeature.IdFeature = 0;
                Assert.ThrowsException <ArgumentException>(() => keyFeatureL.Save(keyFeature));
                keyFeature.IdFeature = -12;
                Assert.ThrowsException <ArgumentException>(() => keyFeatureL.Save(keyFeature));

                keyFeature.IdFeature = 45;
                keyFeature.IdHaspKey = 0;
                Assert.ThrowsException <ArgumentException>(() => keyFeatureL.Save(keyFeature));
                keyFeature.IdHaspKey = -12;
                Assert.ThrowsException <ArgumentException>(() => keyFeatureL.Save(keyFeature));

                keyFeature.StartDate = keyFeature.EndDate.AddDays(-45);
                Assert.ThrowsException <ArgumentException>(() => keyFeatureL.Save(keyFeature));
            }
        }
Beispiel #5
0
        public void GetByIdKeyFeature()
        {
            KeyFeature getById;
            KeyFeature kfExpected = CreateNew(1);

            using (var db = new EntitesContext())
            {
                ClearTable.KeyFeatures(db);
                keyFeatureL = Get(db);
                keyFeatureL.Save(CreateNew());
                getById = keyFeatureL.GetById(1);
            }

            Assert.AreEqual(getById, kfExpected);
        }
Beispiel #6
0
        public void UpdateDuplicateKeyKeyFeature()
        {
            bool update;
            var  keyFeature = CreateNew();

            using (var db = new EntitesContext())
            {
                ClearTable.KeyFeatures(db);
                keyFeatureL = Get(db);
                keyFeatureL.Save(keyFeature);
                keyFeature.IdFeature = 111;
                update = keyFeatureL.Update(CreateNew(2));
            }

            Assert.IsFalse(update);
        }
Beispiel #7
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);
                keyFeatureL = Get(db);
                keyFeatureL.Save(CreateNew());
                Assert.IsFalse(keyFeatureL.Update(kfNoDB));
            }
        }
Beispiel #8
0
        public void UpdateKeyFeature()
        {
            bool update;

            using (var db = new EntitesContext())
            {
                ClearTable.KeyFeatures(db);
                keyFeatureL = Get(db);
                keyFeatureL.Save(CreateNew());

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

            Assert.IsTrue(update);
        }