Esempio n. 1
0
        public void CallMapOnce()
        {
            // Arrange
            var mockedMappingService = new Mock <IMappingService>();
            var mockedPictureService = new Mock <IPictureService>();

            var controller = new PicturesController(mockedMappingService.Object, mockedPictureService.Object);

            // Act
            controller.Index();

            // Assert
            mockedMappingService.Verify(x => x.Map <IEnumerable <PictureViewModel> >(It.IsAny <IEnumerable <Picture> >()), Times.Once);
        }
Esempio n. 2
0
        public void CallGetAllPicturesOnce()
        {
            // Arrange
            var mockedMappingService = new Mock <IMappingService>();
            var mockedPictureService = new Mock <IPictureService>();

            var controller = new PicturesController(mockedMappingService.Object, mockedPictureService.Object);

            // Act
            controller.Index();

            // Assert
            mockedPictureService.Verify(x => x.GetAllPictures(), Times.Once);
        }
Esempio n. 3
0
        public void PicturesController_Index()
        {
            //Arrange
            var pictureRepo = new FakeRepository <Picture>(p => p.PictureID);
            var tagsRepo    = new FakeRepository <Tag>(e => e.TagID);

            //Act
            var controller = new PicturesController(pictureRepo, tagsRepo);

            controller.ControllerContext = new ControllerContext(Context.Object, new RouteData(), controller);
            var result = controller.Index() as ViewResult;

            //Assert
            Assert.IsNotNull(result);
        }