public void MustSaveNewEntityIfValid() { var entity = new Entity() { Id = new Random().Next(1, 1000000), Left = left }; var res = WaesService.SaveOrUpdate(entity); Assert.IsTrue(res); }
public ActionResult PostRight([FromQuery] int id, [FromBody] Entity ent) { try { return(Ok(WaesService.SaveOrUpdate(ent))); } catch (Exception ex) { Console.WriteLine(ex.Message); return(BadRequest(ex.Message)); } }
public ActionResult <ComparerResult> GetDiff(int id) { try { var ent = WaesService.Get(id); return(Ok(Comparer.Compare(ent.Left, ent.Right))); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void MustNOTSaveEntityIfInvalidId() { const string msg = "INVALID ID"; try { var res = WaesService.SaveOrUpdate(new Entity()); } catch (Exception ex) { Assert.IsTrue(ex.Message.Contains(msg)); } }
public void MustNOTSaveEntityIfInvalidLeftAndRight() { const string msg = "INVALID ENTITY"; try { var res = WaesService.SaveOrUpdate(new Entity() { Id = new Random().Next(1000, 2000) }); } catch (Exception ex) { Assert.IsTrue(ex.Message.Contains(msg)); } }
public void MustSaveAndUpdate() { var id = 999; var entity = new Entity() { Id = id, Left = left }; WaesService.SaveOrUpdate(entity); entity = new Entity() { Id = id, Right = right }; WaesService.SaveOrUpdate(entity); var res = WaesService.Get(id); Assert.AreEqual(res.Left, left); Assert.AreEqual(res.Right, right); }
public ActionResult <string> GetRight(int id) => WaesService.Get(id).Right;
public ActionResult <string> GetLeft(int id) => WaesService.Get(id).Left;