public void DBDistrictTest_Get() { DBDistrict db = new DBDistrict(); var resp = db.Get(1); Assert.IsTrue(resp.Name.ToLower().Contains("denmark")); Assert.IsNotNull(resp.PrimarySalesperson); Assert.IsNotNull(resp.SecondarySalespeople); Assert.AreNotEqual(0, resp.SecondarySalespeople.Count()); }
public void UpdateEntityTest() { DBDistrict dB = new DBDistrict(this.dBConnect); var sp = dB.Get(1); Assert.IsNotNull(sp, "Store not retrieved"); var oldName = sp.Name; sp.Name = "Testttt"; dB.Update(sp); Assert.IsTrue(dB.Get(sp.ID).Name != oldName, "Name not changed"); sp.Name = oldName; dB.Update(sp); Assert.IsTrue(dB.Get(sp.ID).Name == oldName, "Name not reverted"); }
// GET api/<controller>/5 public District Get(int id) { var faulted = new District(); try { return(db.Get(id)); } catch (DataLayerArgumentException e) { faulted.IsFaulted = true; faulted.DataLayerArgumentException = e.Message; } catch (DataLayerException e) { faulted.IsFaulted = true; faulted.DataLayerException = e.Message; } return(faulted); }
public IActionResult Get(int id) { try { var dto = provider.Get(id).toDto(); return(Ok(dto)); } catch (Exception e) { return(BadRequest($"ERROR: {e.Message}")); } }
public void DBDistrictTest_Update() { DBDistrict db = new DBDistrict(); const int id = 2; var district = db.Get(id); var nameOld = district.Name; var nameNew = "Norway"; district.Name = nameNew; db.Update(district); district = db.Get(id); Assert.AreEqual(nameNew, district.Name); district.Name = nameOld; db.Update(district); district = db.Get(id); Assert.AreEqual(nameOld, district.Name); }
public void DBDistrictTest_AssignSecondary_DeleteSecondary() { DBDistrict db = new DBDistrict(); var person = new Salesperson() { Id = 3 }; var district = new District() { Id = 1 }; var countOld = db.Get(1).SecondarySalespeople.Count(); db.AssignSecondary(person, district); var countNew = db.Get(1).SecondarySalespeople.Count(); Assert.AreNotEqual(countOld, countNew); db.DeleteSecondary(person, district); countNew = db.Get(1).SecondarySalespeople.Count(); Assert.AreEqual(countOld, countNew); }
public void DBDistrictTest_Get_fail_ID() { DBDistrict db = new DBDistrict(); db.Get(-1); }