public void AddNullClient() { using (var db = new EntitesContext()) { clientDAO = new DbClientDAO(db); Assert.ThrowsException <ArgumentNullException>(() => clientDAO.Add(null)); } }
public void RemoveNoDBClient() { using (var db = new EntitesContext()) { ClearTable.Clients(db); clientDAO = new DbClientDAO(db); clientDAO.Add(CreateNew()); Assert.IsFalse(clientDAO.Remove(123)); } }
public void ContainsDBClient() { var client = CreateNew(); using (var db = new EntitesContext()) { ClearTable.Clients(db); clientDAO = new DbClientDAO(db); clientDAO.Add(client); Assert.IsTrue(clientDAO.ContainsDB(client)); } }
public void NoContainsDBClient() { var client = CreateNew(); using (var db = new EntitesContext()) { ClearTable.Clients(db); clientDAO = new DbClientDAO(db); clientDAO.Add(client); client.Name = "asdasd"; Assert.IsFalse(clientDAO.ContainsDB(client)); } }
public void AddClient() { int idExpected = 1; int add; using (var db = new EntitesContext()) { ClearTable.Clients(db); clientDAO = new DbClientDAO(db); add = clientDAO.Add(CreateNew()); } Assert.AreEqual(add, idExpected); }
public void GetByIdClient() { Client getById; Client clientExpected = CreateNew(1); using (var db = new EntitesContext()) { ClearTable.Clients(db); clientDAO = new DbClientDAO(db); clientDAO.Add(CreateNew()); getById = clientDAO.GetById(1); } Assert.AreEqual(getById, clientExpected); }
public void GetAllClient() { List <Client> getAll; var clients = CreateListEntities.Clients(); using (var db = new EntitesContext()) { ClearTable.Clients(db); clientDAO = new DbClientDAO(db); foreach (var cl in clients) { clientDAO.Add(cl); } getAll = clientDAO.GetAll(); } CollectionAssert.AreEqual(getAll, clients); }
public void UpdateNoDBClient() { Client clientNoDB = new Client { Id = 234, Name = "______", ContactPerson = "______", Address = "______", Phone = "______", }; using (var db = new EntitesContext()) { ClearTable.Clients(db); clientDAO = new DbClientDAO(db); clientDAO.Add(CreateNew()); Assert.IsFalse(clientDAO.Update(clientNoDB)); } }
public void UpdateClient() { bool update; using (var db = new EntitesContext()) { ClearTable.Clients(db); clientDAO = new DbClientDAO(db); clientDAO.Add(CreateNew()); update = clientDAO.Update(new Client { Id = 1, Name = "____", Address = "____", ContactPerson = "____", Phone = "____", }); } Assert.IsTrue(update); }
public bool Save(Client entity) { if (entity == null) { throw new ArgumentNullException(nameof(entity)); } CheckArgument(entity); int id; if (!clientDAO.ContainsDB(entity)) { id = clientDAO.Add(entity); } else { return(false); } return(id > 0); }