public void OpenGallery_ShouldSucceed()
        {
            // Arrange
            _galleryManager.OpenGallery(Arg.Any <string>()).Returns(new ImageGallery("Test name", new List <GalleryImageInfo>
            {
                new GalleryImageInfo("fullname\\name.jpg", true, new CreditsEntry
                {
                    PhotoUrl = "url",
                    UserName = "******",
                    UserUrl  = "userurl",
                })
            }));

            // Act
            _viewModel.OpenGallery();

            // Assert
            _viewModel.Received(1).LoadGallery(Arg.Any <ImageGallery>());
            _viewModel.CurrentImageIndex.Should().Be(0);
            _viewModel.CurrentImage.Should().BeEquivalentTo(new
            {
                FullName         = "fullname\\name.jpg",
                Name             = "name.jpg",
                OriginalFileName = "name",
                Exists           = true,
            });
            _viewModel.CurrentImageName.Should().Be("name.jpg");
            _viewModel.CurrentCredits.Should().BeEquivalentTo(new
            {
                PhotoUrl = "url",
                UserName = "******",
                UserUrl  = "userurl",
            });
        }
예제 #2
0
        public GalleryImageSelectorTests()
        {
            _galleryManager            = Substitute.For <IGalleryManager>();
            _directoryPathProviderMock = Substitute.For <IDirectoryPathProvider>();
            _errorHandlerMock          = Substitute.For <IErrorHandler>();
            _confirmationServiceMock   = Substitute.For <IConfirmationService>();
            _newImageDataProvider      = Substitute.For <INewImageDataProvider>();

            _viewModel = new ImageViewerViewModel(
                _galleryManager,
                _directoryPathProviderMock,
                _errorHandlerMock,
                _confirmationServiceMock,
                _newImageDataProvider);

            _testGallery = new ImageGallery("Test name", new List <GalleryImageInfo>
            {
                new GalleryImageInfo("fullname\\name.jpg", true, new CreditsEntry
                {
                    PhotoUrl = "url",
                    UserName = "******",
                    UserUrl  = "userurl",
                }),
                new GalleryImageInfo("fullname\\name1.jpg", true, new CreditsEntry
                {
                    PhotoUrl = "url1",
                    UserName = "******",
                    UserUrl  = "userurl1",
                }),
                new GalleryImageInfo("fullname\\name2.jpg", true, new CreditsEntry
                {
                    PhotoUrl = "url2",
                    UserName = "******",
                    UserUrl  = "userurl2",
                }),
            });

            _galleryManager.OpenGallery(Arg.Any <string>()).Returns(_testGallery);
            _viewModel.OpenGallery();
        }