Ejemplo n.º 1
0
        public void The_DessertService_can_like_the_dessert()
        {
            //Arrange
            var dessertRepo = new DessertRepository(_unitOfWorkMock.Object);
            var dessertSvc = new DessertService(dessertRepo);
            var oldLikes = _testDessert.Likes;

            //Actions
            var newDessert = dessertSvc.LikeDessert(_testDessert.ID);

            //Assertions
            _unitOfWorkMock.Verify(uow => uow.Get<Dessert>(_dessertGuid));
            _unitOfWorkMock.Verify(uow => uow.Update(_testDessert));
            Assert.That(newDessert.Likes == oldLikes + 1);
        }
Ejemplo n.º 2
0
        public void The_dessert_service_can_call_the_repository_to_save_the_dessert()
        {
            //Arrange
            var service = new DessertService(_dessertRepoMock.Object);

            //Action
            service.Save(_testDessert);

            //Assertions
            _dessertRepoMock.Verify(repo => repo.Save(_testDessert));
        }
Ejemplo n.º 3
0
        public void The_DessertService_can_receive_list_in_order_of_rating_from_repository()
        {
            //Arrange
            IDessertService dessertService = new DessertService(_dessertRepoMock.Object);

            //Action
            IList<Dessert> dessertList = dessertService.GetRatedDesserts(false);

            //Assertions
            _dessertRepoMock.Verify(drm => drm.GetInOrder(dessert => dessert.Likes >= 0
                , dessert => dessert.Likes
                , false), Times.Once());
            Assert.That(dessertList.Count == 2);
            Assert.AreEqual(dessertList[0], _testDessert2);
            Assert.AreEqual(dessertList[1], _testDessert1);
        }