示例#1
0
        public void Update_ArtistLinks()
        {
            // Arrange
            var circle      = repository.Save(CreateEntry.Circle());
            var illustrator = repository.Save(CreateEntry.Artist(ArtistType.Illustrator));

            var contract = new ArtistForEditContract(vocalist, ContentLanguagePreference.English)
            {
                Groups = new[] {
                    new ArtistForArtistContract {
                        Parent = new ArtistContract(circle, ContentLanguagePreference.English)
                    },
                },
                Illustrator = new ArtistContract(illustrator, ContentLanguagePreference.English)
            };

            // Act
            CallUpdate(contract);

            // Assert
            var artistFromRepo = repository.Load(contract.Id);

            Assert.AreEqual(2, artistFromRepo.AllGroups.Count, "Number of groups");
            Assert.IsTrue(artistFromRepo.HasGroup(circle), "Has group");
            Assert.IsTrue(artistFromRepo.HasGroup(illustrator), "Has illustrator");
            Assert.AreEqual(ArtistLinkType.Group, artistFromRepo.Groups.First(g => g.Parent.Equals(circle)).LinkType, "Artist link type for circle");
            Assert.AreEqual(ArtistLinkType.Illustrator, artistFromRepo.Groups.First(g => g.Parent.Equals(illustrator)).LinkType, "Artist link type for illustrator");
        }
示例#2
0
        public void Update_ArtistLinks_ChangeRole()
        {
            // Arrange
            var illustrator = repository.Save(CreateEntry.Artist(ArtistType.Illustrator));

            vocalist.AddGroup(illustrator, ArtistLinkType.Illustrator);

            // Change linked artist from illustrator to voice provider
            var contract = new ArtistForEditContract(vocalist, ContentLanguagePreference.English)
            {
                Illustrator   = null,
                VoiceProvider = new ArtistContract(illustrator, ContentLanguagePreference.English)
            };

            // Act
            CallUpdate(contract);

            // Assert
            vocalist = repository.Load(contract.Id);

            Assert.AreEqual(1, vocalist.AllGroups.Count, "Number of linked artists");

            var link = vocalist.AllGroups[0];

            Assert.AreEqual(illustrator, link.Parent, "Linked artist as expected");
            Assert.AreEqual(ArtistLinkType.VoiceProvider, link.LinkType, "Link type was updated");
        }
示例#3
0
        public async Task Update_ArtistLinks_ChangeRole()
        {
            // Arrange
            var illustrator = _repository.Save(CreateEntry.Artist(ArtistType.Illustrator));

            _vocalist.AddGroup(illustrator, ArtistLinkType.Illustrator);

            // Change linked artist from illustrator to voice provider
            var contract = new ArtistForEditContract(_vocalist, ContentLanguagePreference.English, new InMemoryImagePersister())
            {
                Illustrator   = null,
                VoiceProvider = new ArtistContract(illustrator, ContentLanguagePreference.English)
            };

            // Act
            await CallUpdate(contract);

            // Assert
            _vocalist = _repository.Load(contract.Id);

            _vocalist.AllGroups.Count.Should().Be(1, "Number of linked artists");

            var link = _vocalist.AllGroups[0];

            link.Parent.Should().Be(illustrator, "Linked artist as expected");
            link.LinkType.Should().Be(ArtistLinkType.VoiceProvider, "Link type was updated");
        }
示例#4
0
        public async Task Update_ArtistLinks()
        {
            // Arrange
            var circle      = _repository.Save(CreateEntry.Circle());
            var illustrator = _repository.Save(CreateEntry.Artist(ArtistType.Illustrator));

            var contract = new ArtistForEditContract(_vocalist, ContentLanguagePreference.English, new InMemoryImagePersister())
            {
                Groups = new[] {
                    new ArtistForArtistContract {
                        Parent = new ArtistContract(circle, ContentLanguagePreference.English)
                    },
                },
                Illustrator = new ArtistContract(illustrator, ContentLanguagePreference.English)
            };

            // Act
            await CallUpdate(contract);

            // Assert
            var artistFromRepo = _repository.Load(contract.Id);

            artistFromRepo.AllGroups.Count.Should().Be(2, "Number of groups");
            artistFromRepo.HasGroup(circle).Should().BeTrue("Has group");
            artistFromRepo.HasGroup(illustrator).Should().BeTrue("Has illustrator");
            artistFromRepo.Groups.First(g => g.Parent.Equals(circle)).LinkType.Should().Be(ArtistLinkType.Group, "Artist link type for circle");
            artistFromRepo.Groups.First(g => g.Parent.Equals(illustrator)).LinkType.Should().Be(ArtistLinkType.Illustrator, "Artist link type for illustrator");
        }
        public void SetUp()
        {
            var anotherUser = CreateEntry.User(id: 2);

            artist = CreateEntry.Artist(ArtistType.Producer);
            ArchivedArtistVersion.Create(artist, new ArtistDiff(), new AgentLoginData(anotherUser), ArtistArchiveReason.Created, string.Empty);
            user = CreateEntry.User(id: 1);
        }
 public ArtistRelationsQueryTests()
 {
     artist    = repository.Save(CreateEntry.Artist(ArtistType.Producer));
     voicebank = repository.Save(CreateEntry.Artist(ArtistType.Vocaloid));
     song      = repository.Save(CreateEntry.Song());
     song2     = repository.Save(CreateEntry.Song());
     repository.Save(song.AddArtist(artist));
     repository.Save(song.AddArtist(voicebank));
     repository.Save(song2.AddArtist(artist));
     query = new ArtistRelationsQuery(repository.CreateContext(), Model.Domain.Globalization.ContentLanguagePreference.English, new FakeObjectCache());
 }
示例#7
0
        public ArtistSearchTests()
        {
            artistSearch = new ArtistSearch(ContentLanguagePreference.Default, db.CreateContext(), new EntryUrlParser());

            var artist1 = db.Save(CreateEntry.Artist(ArtistType.Producer, name: "XenonP"));

            db.SaveNames(artist1);
            db.Save(artist1.CreateWebLink("Twitter", "https://twitter.com/XenonP_XM", WebLinkCategory.Official));
            db.SaveNames(db.Save(CreateEntry.Artist(ArtistType.Producer, name: "Clean Tears")));
            db.SaveNames(db.Save(CreateEntry.Artist(ArtistType.Vocaloid, name: "Hatsune Miku")));
        }
示例#8
0
        public void ParseTitle_EmptyParts()
        {
            // "オリジナル・PV" lead to an empty artist name being searched.
            // The database collation matches this with an invalid artist, so empty artist searches are ignored.
            var result = NicoHelper.ParseTitle("【初音ミク】心闇【オリジナル・PV】", val => {
                if (string.IsNullOrEmpty(val))
                {
                    Assert.Fail("Empty name not allowed");
                }
                return(CreateEntry.Artist(ArtistType.Producer, name: val));
            });

            Assert.AreEqual(2, result.Artists.Count, "Number of parsed artists");
        }
        public void SetUp()
        {
            vocalist            = CreateEntry.Artist(ArtistType.Vocaloid, id: 1, name: "GUMI");
            vocalist.ArtistType = ArtistType.Vocaloid;

            producer            = CreateEntry.Artist(ArtistType.Producer, id: 2, name: "devilishP");
            producer.ArtistType = ArtistType.Producer;

            song = new Song(new LocalizedString("5150", ContentLanguageSelection.English))
            {
                SongType = SongType.Original
            };
            song.AddArtist(vocalist);
        }
        public void CanEdit_ApprovedEntry_OwnerUser()
        {
            var artist = CreateEntry.Artist(ArtistType.Producer);
            var user   = CreateEntry.User();

            artist.Status = EntryStatus.Approved;
            user.GroupId  = UserGroupId.Regular;

            user.AddOwnedArtist(artist);

            var result = EntryPermissionManager.CanEdit(new FakePermissionContext(user), artist);

            Assert.IsTrue(result, "result");
        }
        public void SetUp()
        {
            var anotherUser = CreateEntry.User(id: 2);

            _artist = CreateEntry.Artist(ArtistType.Producer);
            ArchivedArtistVersion.Create(_artist, new ArtistDiff(), new AgentLoginData(anotherUser), ArtistArchiveReason.Created, string.Empty);
            _user = CreateEntry.User(id: 1);

            _verifiedArtist = CreateEntry.Artist(ArtistType.Producer);
            _verifiedUser   = CreateEntry.User(id: 3);

            _verifiedArtist.Status = EntryStatus.Approved;
            _verifiedUser.GroupId  = UserGroupId.Regular;
            _verifiedUser.AddOwnedArtist(_verifiedArtist);
        }
示例#12
0
        public async Task FindDuplicates_MatchNameAndArtist()
        {
            var producer2 = Save(CreateEntry.Artist(ArtistType.Producer, name: "minato"));
            var song2     = repository.Save(CreateEntry.Song(name: "Nebula"));

            Save(song2.AddArtist(producer2));

            var result = await CallFindDuplicates(new [] { "Nebula" }, artistIds : new[] { producer2.Id });

            // 2 songs, the one with both artist and title match appears first
            Assert.AreEqual(2, result.Matches.Length, "Matches");
            var match = result.Matches.First();

            Assert.AreEqual(song2.Id, match.Entry.Id, "Matched song");
            Assert.AreEqual(SongMatchProperty.Title, match.MatchProperty, "Matched property");
        }
示例#13
0
        public void Find_ByTwitter_EndsWithP()
        {
            var artist = db.Save(CreateEntry.Artist(ArtistType.Producer, name: "Uji"));

            db.SaveNames(artist);
            db.Save(artist.CreateWebLink("Twitter", "https://twitter.com/Uji_RaychoruiP", WebLinkCategory.Official));

            var result = artistSearch.Find(new ArtistQueryParams {
                Common =
                {
                    TextQuery = ArtistSearchTextQuery.Create("https://twitter.com/Uji_RaychoruiP")
                }
            });

            Assert.AreEqual(1, result.Items.Length, "Got 1 result");
            Assert.AreEqual("Uji", result.Items[0].DefaultName, "Result as expected");
        }
        public void Ctor_IllustratorIsAlsoManager()
        {
            var illustrator = CreateEntry.Artist(ArtistType.Illustrator, id: 1);
            var artist      = CreateEntry.Vocalist(id: 2);

            artist.AddGroup(illustrator, ArtistLinkType.Illustrator);
            artist.AddGroup(illustrator, ArtistLinkType.Manager);

            var result = new ArtistForEditContract(artist, ContentLanguagePreference.Default, new InMemoryImagePersister());

            result.Illustrator?.Id.Should().Be(illustrator.Id, "Illustrator");
            result.AssociatedArtists.Length.Should().Be(1, "Illustrator is included in the associated artists list");
            var managerRole = result.AssociatedArtists.FirstOrDefault();

            managerRole.Should().NotBeNull("Manager");
            managerRole.Parent.Id.Should().Be(illustrator.Id, "Manager is the same as illustrator");
            managerRole.LinkType.Should().Be(ArtistLinkType.Manager, "LinkType");
        }
示例#15
0
        public void Ctor_IllustratorIsAlsoManager()
        {
            var illustrator = CreateEntry.Artist(ArtistType.Illustrator, id: 1);
            var artist      = CreateEntry.Vocalist(id: 2);

            artist.AddGroup(illustrator, ArtistLinkType.Illustrator);
            artist.AddGroup(illustrator, ArtistLinkType.Manager);

            var result = new ArtistForEditContract(artist, ContentLanguagePreference.Default);

            Assert.AreEqual(illustrator.Id, result.Illustrator?.Id, "Illustrator");
            Assert.AreEqual(1, result.AssociatedArtists.Length, "Illustrator is included in the associated artists list");
            var managerRole = result.AssociatedArtists.FirstOrDefault();

            Assert.IsNotNull(managerRole, "Manager");
            Assert.AreEqual(illustrator.Id, managerRole.Parent.Id, "Manager is the same as illustrator");
            Assert.AreEqual(ArtistLinkType.Manager, managerRole.LinkType, "LinkType");
        }
示例#16
0
        public void Create_WithCustomArtists()
        {
            var artist   = repository.Save(CreateEntry.Artist(ArtistType.Producer));
            var contract = new ReleaseEventForEditContract {
                Description  = string.Empty,
                SeriesSuffix = string.Empty,
                Artists      = new [] {
                    new ArtistForEventContract {
                        Artist = new ArtistContract(artist, ContentLanguagePreference.Default)
                    },
                    new ArtistForEventContract {
                        Name = "Miku!"
                    }
                }
            };

            CallUpdate(contract);
        }
示例#17
0
        public void ParseTitle_EmptyParts()
        {
            // "オリジナル・PV" lead to an empty artist name being searched.
            // The database collation matches this with an invalid artist, so empty artist searches are ignored.
            var result = NicoHelper.ParseTitle("【初音ミク】心闇【オリジナル・PV】", val =>
            {
                Action action = () =>
                {
                    if (string.IsNullOrEmpty(val))
                    {
                        throw new InvalidOperationException("Empty name not allowed");
                    }
                };
                action.Should().NotThrow <InvalidOperationException>();
                return(CreateEntry.Artist(ArtistType.Producer, name: val));
            });

            result.Artists.Count.Should().Be(2, "Number of parsed artists");
        }
示例#18
0
        public async Task FindDuplicates_ParsePVInfo_YouTube()
        {
            var artist = repository.Save(CreateEntry.Artist(ArtistType.Producer, name: "Clean Tears"));

            repository.Save(artist.CreateWebLink("YouTube", "https://www.youtube.com/channel/UCnHGCQ0pwnRFF5Oe2YTeOcA", WebLinkCategory.Official));

            var titleParseResult = VideoTitleParseResult.CreateSuccess("Clean Tears - Ruby", "Clean Tears", null, "http://tn.smilevideo.jp/smile?i=32347786", 39);

            titleParseResult.Author   = "Clean Tears";
            titleParseResult.AuthorId = "UCnHGCQ0pwnRFF5Oe2YTeOcA";

            pvParser.MatchedPVs.Add("https://youtu.be/aJKY_EeAeYc",
                                    VideoUrlParseResult.CreateOk("https://youtu.be/aJKY_EeAeYc", PVService.Youtube, "aJKY_EeAeYc", titleParseResult));

            var result = await CallFindDuplicates(new string[0], new[] { "https://youtu.be/aJKY_EeAeYc" });

            Assert.AreEqual("Clean Tears - Ruby", result.Title, "Title");             // Title from PV
            Assert.AreEqual(1, result.Artists.Length, "Number of matched artists");
            Assert.AreEqual(artist.Id, result.Artists[0].Id, "Matched artist");
        }
示例#19
0
        public void SetUp()
        {
            repository = new FakeAlbumRepository();
            var permissionContext = new FakePermissionContext();
            var thumbPersister    = new InMemoryImagePersister();

            queries = new EntryQueries(repository, permissionContext, thumbPersister);

            var group  = CreateEntry.Artist(ArtistType.OtherGroup, name: "1640mP");
            var artist = CreateEntry.Producer(name: "40mP");
            var tag    = new Tag("pop_rock");

            artist.Tags.Usages.Add(new ArtistTagUsage(artist, tag));
            var artist2 = CreateEntry.Producer(name: "Tripshots");
            var album   = CreateEntry.Album(name: "40mP Piano Arrange Album");
            var song    = CreateEntry.Song(name: "Mosaik Role [40mP ver.]");

            repository.Save(group, artist, artist2);
            repository.Save(album);
            repository.Save(song);
            repository.Save(tag);
        }
示例#20
0
        public async Task Create()
        {
            var artist = repository.Save(CreateEntry.Artist(ArtistType.Producer));

            var model = new Create {
                NameOriginal = "Arabian Response",
                PVUrl        = "http://www.nicovideo.jp/watch/sm32982184",
                Artists      = new[] {
                    new ArtistForSongContract {
                        Artist = new ArtistContract(artist, ContentLanguagePreference.Default)
                    }
                }
            };

            var result = await controller.Create(model);

            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult), "result");
            var routeResult = (RedirectToRouteResult)result;

            Assert.AreEqual("Edit", routeResult.RouteValues["Action"], "Action");

            Assert.AreEqual(1, repository.List <Song>().Count, "Song was created");
        }