Пример #1
0
        public HttpResponseMessage Get(int id)
        {
            var handler  = new DashboardComponentGetHandler();
            var response = handler.Handle(id);

            if (handler.Errors == null || handler.Errors.Count < 1)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, response.ComponentDtos[0]));
            }
            return(Request.CreateResponse(HttpStatusCode.BadRequest, handler.Errors));
        }
Пример #2
0
        public void DashboardComponentGetHandlerValidatesItsExistence()
        {
            //Arrange
            var repository = new Mock <IDashboardComponentRepository>();

            repository.Setup(x => x.Exists(It.IsAny <int>())).Returns(false);

            var handler = new DashboardComponentGetHandler(repository.Object);

            //Act
            handler.Handle(1);

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