コード例 #1
0
        public void SortByPriceTest_ReturnsSortedList()
        {
            //Arrange
            var mock = new Mock <IRepository <Edition> >();

            mock.Setup(a => a.List()).Returns(new List <Edition>()
            {
                new Edition()
                {
                    Name                = "Edition",
                    Description         = "Edition is Edition",
                    DateNextPublication = DateTime.UtcNow,
                    Language            = "eng",
                    Price               = 3
                },
                new Edition()
                {
                    Name                = "Edition1",
                    Description         = "Edition is Edition1",
                    DateNextPublication = DateTime.UtcNow,
                    Language            = "eng",
                    Price               = 5
                }
            });
            EditionServices service = new EditionServices(mock.Object);

            //Act
            var result = service.SortByPrice(true);

            //Assert
            Assert.AreEqual(3, result[0].Price);
        }
コード例 #2
0
        public ActionResult SortByPrice(bool order)
        {
            var items    = _editionService.SortByPrice(order);
            var editions = EditionModel.ToModelList(items);

            return(View("Index", editions));
        }