Example #1
0
        public void CoverImageSourceGetter_ForExistingCoverImage_ReturnsImageSourceWithCoverFilePath()
        {
            // Arrange

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

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

            var fileSystemFacade = new Mock <IFileSystemFacade>();

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

            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().BeEquivalentTo(DiscImageSource.ForImage(new Uri("file://Some-Existing-Image.jpg")));
        }
Example #2
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")));
        }