public void GetByFeatureClient() { List <Client> getByFeature; using (var db = new EntitesContext()) { ClearTable.Features(db); ClearTable.KeyFeatures(db); ClearTable.Clients(db); ClearTable.KeyFeatureClients(db); clientL = Get(db); db.Features.AddRange(CreateListEntities.Features()); db.KeyFeatures.AddRange(CreateListEntities.KeyFeatures()); db.Clients.AddRange(CreateListEntities.Clients()); db.KeyFeatureClients.AddRange(CreateListEntities.KeyFeatureClients()); db.SaveChanges(); getByFeature = clientL.GetByFeature(new Feature { Id = 1, Number = 1, Name = "qwe", }); } CollectionAssert.AreEqual(getByFeature, CreateListEntities.Clients()); }
public void GetByClientHaspKey() { List <HaspKey> getByClient; var getByClientExpected = new List <HaspKey> { CreateNew(1), }; var client = new Client { Id = 1, Name = "Ivanov Ivan", }; 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(); getByClient = haspKeyDAO.GetByClient(client); } CollectionAssert.AreEqual(getByClient, getByClientExpected); }
public void GetByPastDueHaspKey() { List <HaspKey> GetByActive; var GetByActiveExpected = new List <HaspKey> { new HaspKey { Id = 2, InnerId = 2, Number = "uz-3", IsHome = true, TypeKey = TypeKey.Pro, } }; 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.GetByPastDue(); } CollectionAssert.AreEqual(GetByActive, GetByActiveExpected); }
public void RemoveKeyFeature() { bool remove; using (var db = new EntitesContext()) { ClearTable.KeyFeatures(db); ClearTable.KeyFeatureClients(db); kfDAO = new DbKeyFeatureDAO(db); db.KeyFeatures.AddRange(CreateListEntities.KeyFeatures()); db.KeyFeatureClients.AddRange(CreateListEntities.KeyFeatureClients()); db.SaveChanges(); remove = kfDAO.Remove(1); } Assert.IsTrue(remove); }
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 RemoveHaspKey() { bool remove; using (var db = new EntitesContext()) { ClearTable.HaspKeys(db); ClearTable.KeyFeatures(db); ClearTable.KeyFeatureClients(db); haspKeyL = Get(db); db.HaspKeys.AddRange(CreateListEntities.HaspKeys()); db.KeyFeatures.AddRange(CreateListEntities.KeyFeatures()); db.KeyFeatureClients.AddRange(CreateListEntities.KeyFeatureClients()); db.SaveChanges(); remove = haspKeyL.Remove(1); } Assert.IsTrue(remove); }
public void GetAllKeyFeature() { var getAll = new List <KeyFeature>(); var keyFeats = CreateListEntities.KeyFeatures(); using (var db = new EntitesContext()) { ClearTable.KeyFeatures(db); keyFeatureL = Get(db); // Добавляем на прямую, чтобы избежать проверки логики. foreach (var kf in keyFeats) { db.KeyFeatures.Add(kf); } db.SaveChanges(); getAll = keyFeatureL.GetAll(); } CollectionAssert.AreEqual(getAll, keyFeats); }
public void GetByNumberKeyClient() { Client getByNumberKey; Client actual = CreateListEntities.Clients()[0]; using (var db = new EntitesContext()) { ClearTable.HaspKeys(db); ClearTable.KeyFeatures(db); ClearTable.Clients(db); ClearTable.KeyFeatureClients(db); clientL = Get(db); db.HaspKeys.AddRange(CreateListEntities.HaspKeys()); db.KeyFeatures.AddRange(CreateListEntities.KeyFeatures()); db.Clients.AddRange(CreateListEntities.Clients()); db.KeyFeatureClients.AddRange(CreateListEntities.KeyFeatureClients()); db.SaveChanges(); getByNumberKey = clientL.GetByNumberKey(1); } Assert.AreEqual(getByNumberKey, actual); }
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); }