Example #1
0
 public void RemoveErroneousIdFeature()
 {
     using (var db = new EntitesContext())
     {
         featureL = Get(db);
         Assert.ThrowsException <ArgumentException>(() => featureL.Remove(erroneousId));
     }
 }
Example #2
0
 public void SaveNullFeature()
 {
     using (var db = new EntitesContext())
     {
         featureL = Get(db);
         Assert.ThrowsException <ArgumentNullException>(() => featureL.Save(null));
     }
 }
Example #3
0
 public void RemoveNoDBFeature()
 {
     using (var db = new EntitesContext())
     {
         ClearTable.Features(db);
         featureL = Get(db);
         featureL.Save(CreateNew());
         Assert.IsFalse(featureL.Remove(1235));
     }
 }
Example #4
0
        public void GetByIdNoDBFeature()
        {
            Feature getById;

            using (var db = new EntitesContext())
            {
                ClearTable.Features(db);
                featureL = Get(db);
                getById  = featureL.GetById(1);
            }
            Assert.IsNull(getById);
        }
Example #5
0
        public void SaveFeature()
        {
            bool add;

            using (var db = new EntitesContext())
            {
                ClearTable.Features(db);
                featureL = Get(db);
                add      = featureL.Save(CreateNew());
            }

            Assert.IsTrue(add);
        }
Example #6
0
        public KeyFeatureModel(IFactoryLogic factoryLogic)
        {
            this.factoryLogic = factoryLogic ?? throw new ArgumentNullException(nameof(factoryLogic));

            db = Context.GetContext();
            if (db == null)
            {
                throw new ArgumentNullException(nameof(db));
            }

            featLogic       = this.factoryLogic.CreateFeature(db);
            keyFeatureLogic = this.factoryLogic.CreateKeyFeature(db);
        }
Example #7
0
        public FeatureModel(IFactoryLogic factoryLogic)
        {
            if (factoryLogic == null)
            {
                throw new ArgumentNullException(nameof(factoryLogic));
            }

            db = Context.GetContext();
            if (db == null)
            {
                throw new ArgumentNullException(nameof(db));
            }
            featLogic = factoryLogic.CreateFeature(db);
        }
Example #8
0
        public void GetAllEmptyFeature()
        {
            var getAll          = new List <Feature>();
            var featureExpected = new List <Feature>();

            using (var db = new EntitesContext())
            {
                ClearTable.Features(db);
                featureL = Get(db);
                getAll   = featureL.GetAll();
            }

            CollectionAssert.AreEqual(getAll, featureExpected);
        }
Example #9
0
        public void GetByIdFeature()
        {
            Feature getById;
            Feature featureExpected = CreateNew(1);

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

            Assert.AreEqual(getById, featureExpected);
        }
Example #10
0
        public void SaveDuplicateFeature()
        {
            bool    add;
            Feature feature = CreateNew();

            using (var db = new EntitesContext())
            {
                ClearTable.Features(db);
                featureL = Get(db);
                featureL.Save(feature);
                add = featureL.Save(feature);
            }

            Assert.IsFalse(add);
        }
Example #11
0
        public void UpdateDuplicateFeature()
        {
            bool update;
            var  faeture = CreateNew();

            using (var db = new EntitesContext())
            {
                ClearTable.Features(db);
                featureL = Get(db);
                featureL.Save(faeture);
                faeture.Number = 111;
                featureL.Save(faeture);
                update = featureL.Update(CreateNew(2));
            }
            Assert.IsFalse(update);
        }
Example #12
0
        public void UpdateNoDBFeature()
        {
            var featureNoDB = new Feature
            {
                Id          = 234234,
                Number      = 54,
                Name        = "____________",
                Description = "ssdsssss",
            };

            using (var db = new EntitesContext())
            {
                ClearTable.Features(db);
                featureL = Get(db);
                featureL.Save(CreateNew());
                Assert.IsFalse(featureL.Update(featureNoDB));
            }
        }
Example #13
0
        public void UpdateFeature()
        {
            bool update;

            using (var db = new EntitesContext())
            {
                ClearTable.Features(db);
                featureL = Get(db);
                featureL.Save(CreateNew());
                update = featureL.Update(new Feature
                {
                    Id          = 1,
                    Number      = 1002,
                    Name        = "TestUpdate",
                    Description = "Test ______",
                });
            }
            Assert.IsTrue(update);
        }
Example #14
0
        public void GetAllFeature()
        {
            var getAll   = new List <Feature>();
            var features = CreateListEntities.Features();

            using (var db = new EntitesContext())
            {
                ClearTable.Features(db);
                featureL = Get(db);

                foreach (var feat in features)
                {
                    featureL.Save(feat);
                }

                getAll = featureL.GetAll();
            }

            CollectionAssert.AreEqual(getAll, features);
        }
Example #15
0
        public void ErroneousArgumentSaveFeature()
        {
            Feature feature = CreateNew();

            using (var db = new EntitesContext())
            {
                ClearTable.Features(db);
                featureL = Get(db);

                feature.Name = null;
                Assert.ThrowsException <ArgumentException>(() => featureL.Save(feature));
                feature.Name = string.Empty;
                Assert.ThrowsException <ArgumentException>(() => featureL.Save(feature));

                feature.Name   = "_____";
                feature.Number = 0;
                Assert.ThrowsException <ArgumentException>(() => featureL.Save(feature));
                feature.Number = -456;
                Assert.ThrowsException <ArgumentException>(() => featureL.Save(feature));
            }
        }
Example #16
0
        public void RemoveFeature()
        {
            bool remove;

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

                featureL = Get(db);
                db.Features.AddRange(CreateListEntities.Features());
                db.KeyFeatures.AddRange(CreateListEntities.KeyFeatures());
                db.KeyFeatureClients.AddRange(CreateListEntities.KeyFeatureClients());
                db.SaveChanges();

                remove = featureL.Remove(1);
            }

            Assert.IsTrue(remove);
        }
Example #17
0
 public FeatureController(IFeatureLogic featureLogic)
 {
     _featureLogic = featureLogic;
 }
Example #18
0
 public void NullEntitesContextFeature()
 {
     Assert.ThrowsException <ArgumentNullException>(() => featureL = Get(null));
 }