// GET api/<controller> public IEnumerable <Store> Get() { var faulted = new List <Store>(); try { return(db.GetAll()); } catch (DatabaseLink.DataLayerArgumentException e) { faulted.Add(new Store() { IsFaulted = true, DataLayerArgumentException = e.Message }); } catch (DatabaseLink.DataLayerException e) { if (faulted.Count == 0) { faulted.Add(new Store() { IsFaulted = true }); } faulted[0].DataLayerException = e.Message; } return(faulted); }
public void GetAllTest() { DBStore dB = new DBStore(this.dBConnect); var ppl = dB.GetAll(); Assert.IsNotNull(ppl, "Null object returned"); Assert.IsTrue(ppl.Count() > 0, "There are no stores"); }
public void DBStoreTest_getAll() { DBStore db = new DBStore(); var stores = db.GetAll(); Assert.AreNotEqual(0, stores.ToList().Count); Assert.AreEqual("Shop 1", stores.ToList()[0].Name); Assert.IsNotNull(stores.ToList()[2].District); }
public IActionResult Get() { try { return(Ok(provider.GetAll().allToDto())); } catch (Exception e) { return(BadRequest($"ERROR: {e.Message}")); } }
public void AddRemoveEntityTest() { DBStore dB = new DBStore(this.dBConnect); var sp = new Store() { Name = "Netto", DistrictID = 1 }; var stores = dB.GetAll(); var oldCount = stores.Count(); dB.Create(sp); Assert.IsTrue(dB.GetAll().Count() > oldCount, "Store not created"); stores = dB.GetAll(); sp = stores.Last(); dB.Delete(sp.ID); Assert.IsTrue(dB.GetAll().Count() == oldCount, "Store not removed"); }
public void DBStoreTest_Persist_Delete() { DBStore db = new DBStore(); var store = new Store() { Name = "Nike", Address = "Milton Road 4420", District = new District() { Id = 2 } }; db.Persist(store); var selected = db.GetAll().ToList().SingleOrDefault(x => { return(x.Name == "Nike" && x.Address == "Milton Road 4420"); }); db.Delete(selected.Id); }