Ejemplo n.º 1
0
        public async Task eDelete()
        {
            ActionResult <IEnumerable <Vehicle> > actionresult = await _controller.GetVehicle();

            dbTrucks = ((List <Vehicle>)actionresult.Value);
            try
            {
                foreach (Vehicle v in dbTrucks)
                {
                    await _controller.DeleteVehicle(v.Id);
                }
                actionresult = await _controller.GetVehicle();

                dbTrucks = ((List <Vehicle>)actionresult.Value);
            }
            catch (Exception e)
            {
                Assert.Fail(e.Message);
            }
            if (dbTrucks.Count == 0)
            {
                Assert.Pass();
            }
            else
            {
                Assert.Fail();
            }
        }
Ejemplo n.º 2
0
        public async Task DeleteTest()
        {
            var mapper               = new Mock <IMapper>();
            var repository           = new Mock <IVehicleRepository>();
            var unitOfWork           = new Mock <IUnitOfWork>();
            IVehicleRepository _repo = new MockVehicleRepository();

            var _test   = new VehiclesController(mapper.Object, _repo, unitOfWork.Object);
            var vehicle = await _test.DeleteVehicle(0);

            Assert.IsInstanceOf <ObjectResult>(vehicle);

            var objectResponse = vehicle as ObjectResult;

            Assert.AreEqual(200, objectResponse.StatusCode);
        }