public void AddNullKeyFeature() { using (var db = new EntitesContext()) { kfDAO = new DbKeyFeatureDAO(db); Assert.ThrowsException <ArgumentNullException>(() => kfDAO.Add(null)); } }
public void RemoveNoDBKeyFeature() { using (var db = new EntitesContext()) { ClearTable.KeyFeatures(db); kfDAO = new DbKeyFeatureDAO(db); kfDAO.Add(CreateNew()); Assert.IsFalse(kfDAO.Remove(123)); } }
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)); } }
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); }
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); }
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)); } }
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); }
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); }
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); }