Esempio n. 1
0
        /********************************************************
        **** GET
        ********************************************************/

        /// <summary>
        /// Gets a specified ShoppinglistDto.
        /// </summary>
        /// <param name="id">The Shoppinglist identifier.</param>
        /// <returns>IHttpActionResult.</returns>
        public IHttpActionResult Get(int id)
        {
            var shoppinglist = _service.Get(id);

            if (shoppinglist == null)
            {
                return(NotFound());
            }

            return(Ok(Mapper.Map <Shoppinglist, ShoppinglistDto>(shoppinglist)));
        }
Esempio n. 2
0
        public void Get_IdOne_Returns_Shoppinglist()
        {
            // Arrange
            var mockRepo = new Mock <IShoppinglistRepository>();

            mockRepo.Setup(m => m.GetWithProducts(1))
            .Returns(
                new Shoppinglist {
                Id = 1, Name = "Test"
            }
                );
            var mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork.Setup(uow => uow.Shoppinglists).Returns(mockRepo.Object);

            ShoppinglistService service = new ShoppinglistService(mockUnitOfWork.Object);

            // Act
            var actual = service.Get(1);

            // Assert
            Assert.IsTrue(actual.GetType() == typeof(Shoppinglist));
        }
Esempio n. 3
0
 /// <summary>
 ///A detailed Shoppinglist
 /// </summary>
 /// <param name="id">The Shoppinglist identifier.</param>
 /// <returns>ActionResult.</returns>
 public ActionResult Details(int id)
 {
     return(View(_service.Get(id)));
 }