コード例 #1
0
        public void ReturnCorrectResult()
        {
            // Arrange
            var mockedGalleryCollection = new List <ImageGalleryModel>()
            {
                new ImageGalleryModel()
            };

            var mockedImageGalleryService = new Mock <IImageGalleryService>();

            mockedImageGalleryService.Setup(g => g.GetByLake(It.IsAny <string>()))
            .Returns(mockedGalleryCollection)
            .Verifiable();

            var mockedImageFactory        = new Mock <IImageFactory>();
            var mockedDateProvider        = new Mock <IDateProvider>();
            var mockedLakeService         = new Mock <ILakeService>();
            var mockedImageGalleryFactory = new Mock <IImageGalleryFactory>();
            var mockedDirectoryHelper     = new Mock <IDirectoryHelper>();

            var controller = new PicturesController(
                mockedImageGalleryService.Object,
                mockedImageFactory.Object,
                mockedDateProvider.Object,
                mockedLakeService.Object,
                mockedImageGalleryFactory.Object,
                mockedDirectoryHelper.Object);

            var result         = controller.GetGalleries("test") as string;
            var expectedResult = JsonConvert.SerializeObject(mockedGalleryCollection);

            // Assert
            Assert.AreEqual(expectedResult, result);
            mockedImageGalleryService.Verify(s => s.GetByLake("test"), Times.Once);
        }