Exemplo n.º 1
0
        public void ShouldFetchAllComplaintsFromDb(string title, string description)
        {
            // Arrange
            using var context = new ComplaintsContext(DbFixtureProvider.CreateNewContextOptions());
            var complaintService       = new ComplaintService(context);
            var complaintEntityEntries = new List <EntityEntry <ComplaintEntity> >();
            var complaintIds           = new List <int>();

            for (var i = 0; i < 5; i++)
            {
                complaintEntityEntries.Add(
                    context.Complaints.Add(new ComplaintEntity
                {
                    Title       = title,
                    Description = description
                }));
            }

            context.SaveChanges();

            // Act
            var complaintsInDb = complaintService.GetAll().ToList();

            // Assert
            Assert.Equal(complaintsInDb.Count, complaintEntityEntries.Count);
            foreach (var complaint in complaintEntityEntries)
            {
                Assert.NotNull(complaintsInDb.Find(x => x.Id == complaint.Entity.Id));
            }
        }
Exemplo n.º 2
0
 //GET: api/complaint
 public IHttpActionResult Get()
 {
     try
     {
         return(Ok(_complaintService.GetAll()));
     }
     catch (Exception ec)
     {
         return(BadRequest(ec.Message));
     }
 }
Exemplo n.º 3
0
        public ActionResult Read([DataSourceRequest] DataSourceRequest request)
        {
            DataSourceResult result = _complaintService.GetAll().ToDataSourceResult(request);

            return(Json(result));
        }