Exemple #1
0
        public void should_disambiguate_with_numbers_if_author_folder_exists_and_no_disambiguation()
        {
            var newAuthor = new Author
            {
                ForeignAuthorId = "ce09ea31-3d4a-4487-a797-e315175457a0",
                Path            = @"C:\Test\Music\Name1",
            };

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

            GivenValidAuthor(newAuthor.ForeignAuthorId);
            GivenValidPath();

            Mocker.GetMock <IAuthorService>()
            .Setup(x => x.AuthorPathExists(newAuthor.Path))
            .Returns(true);

            Mocker.GetMock <IAuthorService>()
            .Setup(x => x.AuthorPathExists(newAuthor.Path + " (1)"))
            .Returns(true);

            Mocker.GetMock <IAuthorService>()
            .Setup(x => x.AuthorPathExists(newAuthor.Path + " (2)"))
            .Returns(true);

            var author = Subject.AddAuthor(newAuthor);

            author.Path.Should().Be(newAuthor.Path + " (3)");
        }
Exemple #2
0
        public void should_disambiguate_with_numbers_if_artist_folder_still_exists()
        {
            var newArtist = new Author
            {
                ForeignAuthorId = "ce09ea31-3d4a-4487-a797-e315175457a0",
                Path            = @"C:\Test\Music\Name1",
            };

            _fakeArtist.Metadata = Builder <AuthorMetadata> .CreateNew().With(x => x.Disambiguation = "Disambiguation").Build();

            GivenValidArtist(newArtist.ForeignAuthorId);
            GivenValidPath();

            Mocker.GetMock <IAuthorService>()
            .Setup(x => x.AuthorPathExists(newArtist.Path))
            .Returns(true);

            Mocker.GetMock <IAuthorService>()
            .Setup(x => x.AuthorPathExists(newArtist.Path + " (Disambiguation)"))
            .Returns(true);

            Mocker.GetMock <IAuthorService>()
            .Setup(x => x.AuthorPathExists(newArtist.Path + " (Disambiguation) (1)"))
            .Returns(true);

            Mocker.GetMock <IAuthorService>()
            .Setup(x => x.AuthorPathExists(newArtist.Path + " (Disambiguation) (2)"))
            .Returns(true);

            var artist = Subject.AddAuthor(newArtist);

            artist.Path.Should().Be(newArtist.Path + " (Disambiguation) (3)");
        }
Exemple #3
0
        public void should_have_proper_path()
        {
            var newAuthor = new Author
            {
                ForeignAuthorId = "ce09ea31-3d4a-4487-a797-e315175457a0",
                RootFolderPath  = @"C:\Test\Music"
            };

            GivenValidAuthor(newAuthor.ForeignAuthorId);
            GivenValidPath();

            var author = Subject.AddAuthor(newAuthor);

            author.Path.Should().Be(Path.Combine(newAuthor.RootFolderPath, _fakeAuthor.Name));
        }
Exemple #4
0
        public void should_be_able_to_add_a_author_without_passing_in_name()
        {
            var newAuthor = new Author
            {
                ForeignAuthorId = "ce09ea31-3d4a-4487-a797-e315175457a0",
                RootFolderPath  = @"C:\Test\Music"
            };

            GivenValidAuthor(newAuthor.ForeignAuthorId);
            GivenValidPath();

            var author = Subject.AddAuthor(newAuthor);

            author.Name.Should().Be(_fakeAuthor.Name);
        }
Exemple #5
0
        public void should_throw_if_author_validation_fails()
        {
            var newAuthor = new Author
            {
                ForeignAuthorId = "ce09ea31-3d4a-4487-a797-e315175457a0",
                Path            = @"C:\Test\Music\Name1"
            };

            GivenValidAuthor(newAuthor.ForeignAuthorId);

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

            Assert.Throws <ValidationException>(() => Subject.AddAuthor(newAuthor));
        }
Exemple #6
0
        public void should_throw_if_author_cannot_be_found()
        {
            var newAuthor = new Author
            {
                ForeignAuthorId = "ce09ea31-3d4a-4487-a797-e315175457a0",
                Path            = @"C:\Test\Music\Name1"
            };

            Mocker.GetMock <IProvideAuthorInfo>()
            .Setup(s => s.GetAuthorInfo(newAuthor.ForeignAuthorId, true))
            .Throws(new AuthorNotFoundException(newAuthor.ForeignAuthorId));

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

            Assert.Throws <ValidationException>(() => Subject.AddAuthor(newAuthor));

            ExceptionVerification.ExpectedErrors(1);
        }