public void GetAll_IdOne_Returns_ThreeRows()
        {
            // Arrange
            IEnumerable <Shoppinglist> shoppinglists = new[] {
                new Shoppinglist {
                    Id = 1, Name = "Test"
                },
                new Shoppinglist {
                    Id = 2, Name = "Test2"
                },
                new Shoppinglist {
                    Id = 3, Name = "Test3"
                }
            };
            var mockRepo = new Mock <IShoppinglistRepository>();

            mockRepo.Setup(m => m.GetAllWithProducts())
            .Returns(
                shoppinglists
                );
            var mockUnitOfWork = new Mock <IUnitOfWork>();

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

            ShoppinglistService service = new ShoppinglistService(mockUnitOfWork.Object);

            // Act
            var actual = service.GetAll();

            // Assert
            Assert.AreEqual(3, actual.Count());
        }
Beispiel #2
0
        /// <summary>
        /// Gets all ShoppinglistDtos.
        /// </summary>
        /// <returns>IHttpActionResult.</returns>
        public IHttpActionResult GetAll()
        {
            var shoppinglistDtos = _service.GetAll()
                                   .Select(Mapper.Map <Shoppinglist, ShoppinglistDto>);

            return(Ok(shoppinglistDtos));
        }