public void Delete_By_Id(int id)
        {
            if (id == 0)
            {
                // Should return an error if the id passed is 0
                Assert.Throws <ArgumentException>(() =>
                {
                    _genericUserService.DeleteById(id);
                });
            }
            else if (id == 1)
            {
                var user = _genericUserService.GetById(id);

                _genericUserService.DeleteById(id);

                // This method only inactivates the record, but database queries return only active records.
                // This was designed in this way to recover a record deleted by accident, for data analysis,
                // among other possibilities.
                Assert.Null(_genericUserService.GetById(id));
                Assert.Null(_genericUserService.GetAll().FirstOrDefault(x => x.Id == id));
            }
            else
            {
                // Should return an error if the id passed is not found
                Assert.Throws <ArgumentNullException>(() =>
                {
                    _genericUserService.DeleteById(id);
                });
            }
        }
Ejemplo n.º 2
0
 public void DeleteById(int id)
 {
     service.DeleteById(id);
 }