Exemple #1
0
        public async Task GetAnimalsInEachKennelAsyncTest()
        {
            var kennelProcessor = new KennelProcessor(_mockContext.Object);
            var report          = await kennelProcessor.GetAnimalsInEachKennelAsync();

            var smallKennelReport  = report.Where(r => r.name == "small").FirstOrDefault();
            var mediumKennelReport = report.Where(r => r.name == "medium").FirstOrDefault();
            var largeKennelReport  = report.Where(r => r.name == "large").FirstOrDefault();

            Assert.IsTrue(smallKennelReport.animals.Count == 2);
            Assert.IsTrue(mediumKennelReport.animals.Count == 1);
            Assert.IsTrue(largeKennelReport.animals.Count == 2);
        }
Exemple #2
0
        public async Task <HttpResponseMessage> ReportAsync()
        {
            try
            {
                var kennelReport = await _kennelProcessor.GetAnimalsInEachKennelAsync();

                return(Request.CreateResponse(HttpStatusCode.OK, kennelReport));
            }
            catch (Exception ex)
            {
                //Consideration: Add logger i.e. logger.error(ex)
                return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Error generating report.", ex));
            }
        }