예제 #1
0
        public void CoverImageSourceGetter_IfCoverImageIsMissing_ReturnsImageSourceForMissingImage()
        {
            // Arrange

            var disc = new DiscModel().MakeActive();

            disc.AddImage(new DiscImageModel {
                ImageType = DiscImageType.Cover, ContentUri = new Uri("file://Some-Missing-Image.jpg")
            });

            var fileSystemFacade = new Mock <IFileSystemFacade>();

            fileSystemFacade.Setup(x => x.FileExists("file://Some-Missing-Image.jpg")).Returns(false);

            var mocker = new AutoMocker();

            mocker.Use(fileSystemFacade);

            var target = mocker.CreateInstance <DiscImageViewModel>();

            Messenger.Default.Send(new ActiveDiscChangedEventArgs(disc));

            // Act

            var currentImageUri = target.CoverImageSource;

            // Assert

            currentImageUri.Should().Be(DiscImageSource.ForMissingImage);
        }
예제 #2
0
        public async Task SetDiscCoverImage(DiscModel disc, DiscImageModel coverImage, Stream imageContent, CancellationToken cancellationToken)
        {
            if (disc.CoverImage != null)
            {
                await DeleteDiscCoverImage(disc.CoverImage, cancellationToken);
            }

            disc.AddImage(coverImage);
            await AddDiscCoverImage(coverImage, imageContent, cancellationToken);
        }
예제 #3
0
        public void ActiveDiscChangedEventHandler_RaisesPropertyChangedEventForCoverImageSource()
        {
            // Arrange

            var disc1 = new DiscModel().MakeActive();

            disc1.AddImage(new DiscImageModel {
                ImageType = DiscImageType.Cover, ContentUri = new Uri("file://image1.jpg")
            });

            var disc2 = new DiscModel().MakeActive();

            disc2.AddImage(new DiscImageModel {
                ImageType = DiscImageType.Cover, ContentUri = new Uri("file://image2.jpg")
            });

            var fileSystemFacade = new Mock <IFileSystemFacade>();

            fileSystemFacade.Setup(x => x.FileExists(It.IsAny <string>())).Returns(true);

            var mocker = new AutoMocker();

            mocker.Use(fileSystemFacade);

            var target = mocker.CreateInstance <DiscImageViewModel>();

            Messenger.Default.Send(new ActiveDiscChangedEventArgs(disc1));

            var propertyChangedEvents = new List <PropertyChangedEventArgs>();

            target.PropertyChanged += (_, e) => propertyChangedEvents.Add(e);

            // Act

            Messenger.Default.Send(new ActiveDiscChangedEventArgs(disc2));

            // Assert

            propertyChangedEvents.Select(e => e.PropertyName).Should().Contain(nameof(DiscImageViewModel.CoverImageSource));
            target.CoverImageSource.Should().BeEquivalentTo(DiscImageSource.ForImage(new Uri("file://image2.jpg")));
        }