Exemplo n.º 1
0
        public void MustSaveNewEntityIfValid()
        {
            var entity = new Entity()
            {
                Id = new Random().Next(1, 1000000), Left = left
            };
            var res = WaesService.SaveOrUpdate(entity);

            Assert.IsTrue(res);
        }
Exemplo n.º 2
0
 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));
     }
 }
Exemplo n.º 3
0
 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));
     }
 }
Exemplo n.º 4
0
        public void MustNOTSaveEntityIfInvalidId()
        {
            const string msg = "INVALID ID";

            try
            {
                var res = WaesService.SaveOrUpdate(new Entity());
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.Message.Contains(msg));
            }
        }
Exemplo n.º 5
0
        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));
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 public ActionResult <string> GetRight(int id) => WaesService.Get(id).Right;
Exemplo n.º 8
0
 public ActionResult <string> GetLeft(int id) => WaesService.Get(id).Left;