Ejemplo n.º 1
0
        public void should_disambiguate_with_numbers_if_artist_folder_exists_and_no_disambiguation()
        {
            var newArtist = new Artist
            {
                ForeignArtistId = "ce09ea31-3d4a-4487-a797-e315175457a0",
                Path            = @"C:\Test\Music\Name1",
            };

            _fakeArtist.Metadata = Builder <ArtistMetadata> .CreateNew().With(x => x.Disambiguation = string.Empty).Build();

            GivenValidArtist(newArtist.ForeignArtistId);
            GivenValidPath();

            Mocker.GetMock <IArtistService>()
            .Setup(x => x.ArtistPathExists(newArtist.Path))
            .Returns(true);

            Mocker.GetMock <IArtistService>()
            .Setup(x => x.ArtistPathExists(newArtist.Path + " (1)"))
            .Returns(true);

            Mocker.GetMock <IArtistService>()
            .Setup(x => x.ArtistPathExists(newArtist.Path + " (2)"))
            .Returns(true);

            var artist = Subject.AddArtist(newArtist);

            artist.Path.Should().Be(newArtist.Path + " (3)");
        }
Ejemplo n.º 2
0
        public void should_have_proper_path()
        {
            var newArtist = new Artist
            {
                ForeignArtistId = "ce09ea31-3d4a-4487-a797-e315175457a0",
                RootFolderPath  = @"C:\Test\Music"
            };

            GivenValidArtist(newArtist.ForeignArtistId);
            GivenValidPath();

            var artist = Subject.AddArtist(newArtist);

            artist.Path.Should().Be(Path.Combine(newArtist.RootFolderPath, _fakeArtist.Name));
        }
Ejemplo n.º 3
0
        public void should_be_able_to_add_a_artist_without_passing_in_name()
        {
            var newArtist = new Artist
            {
                ForeignArtistId = "ce09ea31-3d4a-4487-a797-e315175457a0",
                RootFolderPath  = @"C:\Test\Music"
            };

            GivenValidArtist(newArtist.ForeignArtistId);
            GivenValidPath();

            var artist = Subject.AddArtist(newArtist);

            artist.Name.Should().Be(_fakeArtist.Name);
        }
Ejemplo n.º 4
0
        public void should_throw_if_artist_validation_fails()
        {
            var newArtist = new Artist
            {
                ForeignArtistId = "ce09ea31-3d4a-4487-a797-e315175457a0",
                Path            = @"C:\Test\Music\Name1"
            };

            GivenValidArtist(newArtist.ForeignArtistId);

            Mocker.GetMock <IAddArtistValidator>()
            .Setup(s => s.Validate(It.IsAny <Artist>()))
            .Returns(new ValidationResult(new List <ValidationFailure>
            {
                new ValidationFailure("Path", "Test validation failure")
            }));

            Assert.Throws <ValidationException>(() => Subject.AddArtist(newArtist));
        }
Ejemplo n.º 5
0
        public void should_throw_if_artist_cannot_be_found()
        {
            var newArtist = new Artist
            {
                ForeignArtistId = "ce09ea31-3d4a-4487-a797-e315175457a0",
                Path            = @"C:\Test\Music\Name1"
            };

            Mocker.GetMock <IProvideArtistInfo>()
            .Setup(s => s.GetArtistInfo(newArtist.ForeignArtistId, newArtist.MetadataProfileId))
            .Throws(new ArtistNotFoundException(newArtist.ForeignArtistId));

            Mocker.GetMock <IAddArtistValidator>()
            .Setup(s => s.Validate(It.IsAny <Artist>()))
            .Returns(new ValidationResult(new List <ValidationFailure>
            {
                new ValidationFailure("Path", "Test validation failure")
            }));

            Assert.Throws <ValidationException>(() => Subject.AddArtist(newArtist));

            ExceptionVerification.ExpectedErrors(1);
        }