Example #1
0
        public HttpResponseMessage Get(int id)
        {
            var handler  = new DashboardGetHandler();
            var response = handler.Handle(id);

            if (handler.Errors == null || handler.Errors.Count < 1)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, response.DashboardDtos[0]));
            }
            return(Request.CreateResponse(HttpStatusCode.BadRequest, handler.Errors));
        }
Example #2
0
        public void DashboardGetHandlerValidatesExistence()
        {
            //Arrange
            var repository = new Mock<IDashboardRepository>();
            repository.Setup(x => x.Exists(It.IsAny<int>())).Returns(false);

            var handler = new DashboardGetHandler(repository.Object);
            //Act
            handler.Handle(1);

            //Assert
            Assert.IsNotNull(handler.Errors);
            Assert.IsTrue(handler.Errors.Count > 0);
        }