public void SetUp() { producer = CreateEntry.Producer(id: 1, name: "Tripshots"); vocalist = CreateEntry.Vocalist(id: 39, name: "Hatsune Miku"); vocalist2 = CreateEntry.Vocalist(id: 40, name: "Kagamine Rin"); song = CreateEntry.Song(id: 1, name: "Nebula"); song.LengthSeconds = 39; repository = new FakeSongRepository(song); Save(song.AddArtist(producer)); Save(song.AddArtist(vocalist)); Save(song.CreatePV(new PVContract { Service = PVService.Youtube, PVId = "hoLu7c2XZYU", Name = "Nebula", PVType = PVType.Original })); foreach (var name in song.Names) { repository.Save(name); } user = CreateEntry.User(id: 1, name: "Miku"); user.GroupId = UserGroupId.Trusted; user2 = CreateEntry.User(id: 2, name: "Rin", email: "*****@*****.**"); repository.Add(user, user2); repository.Add(producer, vocalist); repository.Add(new Tag("vocarock"), new Tag("vocaloud")); permissionContext = new FakePermissionContext(user); var entryLinkFactory = new EntryAnchorFactory("http://test.vocadb.net"); newSongContract = new CreateSongContract { SongType = SongType.Original, Names = new[] { new LocalizedStringContract("Resistance", ContentLanguageSelection.English) }, Artists = new[] { new ArtistContract(producer, ContentLanguagePreference.Default), new ArtistContract(vocalist, ContentLanguagePreference.Default), }, PVUrl = "http://test.vocadb.net/" }; pvParser = new FakePVParser(); pvParser.ResultFunc = (url, getMeta) => VideoUrlParseResult.CreateOk(url, PVService.NicoNicoDouga, "sm393939", getMeta ? VideoTitleParseResult.CreateSuccess("Resistance", "Tripshots", "testimg.jpg", 39) : VideoTitleParseResult.Empty); mailer = new FakeUserMessageMailer(); queries = new SongQueries(repository, permissionContext, entryLinkFactory, pvParser, mailer, new FakeLanguageDetector()); }
public void SetUp() { _album = new Album(new LocalizedString("Synthesis", ContentLanguageSelection.English)); _producer = new Artist(TranslatedString.Create("Tripshots")) { Id = 1, ArtistType = ArtistType.Producer }; _vocalist = new Artist(TranslatedString.Create("Hatsune Miku")) { Id = 39, ArtistType = ArtistType.Vocaloid }; _producerContract = new ArtistContract(_producer, ContentLanguagePreference.Default); _vocalistContract = new ArtistContract(_vocalist, ContentLanguagePreference.Default); _song1 = new Song(new LocalizedString("Nebula", ContentLanguageSelection.English)) { Id = 2 }; _song1.AddArtist(_producer); _album.AddArtist(_producer); _album.AddArtist(_vocalist); var songInAlbum = new SongInAlbum(_song1, _album, 1, 1); _songInAlbumContract = new SongInAlbumEditContract(songInAlbum, ContentLanguagePreference.Default); _songInAlbumContract.Artists = new[] { _producerContract }; }
public void SetUp() { producer = new Artist(TranslatedString.Create("Tripshots")) { ArtistType = ArtistType.Producer }; vocalist = new Artist(new TranslatedString("初音ミク", "Hatsune Miku", "Hatsune Miku")) { ArtistType = ArtistType.Vocaloid }; song = new Song(new LocalizedString("Nebula", ContentLanguageSelection.English)); song.AddArtist(producer); song.AddArtist(vocalist); song.UpdateArtistString(); album = new Album(new LocalizedString("Synthesis", ContentLanguageSelection.English)); album.AddSong(song, trackNum: 5, discNum: 1); target = new TagFormatter(); }
static void Main(string[] args) { Song song1 = new Song("Song1", 2, "Artist1"); Song song2 = new Song("Song2", 2, "Artist2"); Artist artist3 = new Artist("Artist3"); Composition composition = new Composition("Composition1", 2, artist3, "artist4"); song1.AddArtist("Artist5"); song2.AddArtist("Artist6"); composition.AddArtist("Artist7"); ITrack[] tracks = new ITrack[3]; tracks[0] = song1; tracks[1] = song2; tracks[2] = composition; foreach (ITrack itrack in tracks) { if (itrack != null && itrack.GetArtists() != null) { foreach (Artist artist in itrack.GetArtists()) { Console.WriteLine(artist.Name); } } } Console.ReadLine(); }
private void AddArtist(Song song, Artist artist) { if (!song.HasArtist(artist)) { song.AddArtist(artist); } }
public void SetUp() { querySource = new QuerySourceList(); artist = new Artist(TranslatedString.Create("Junk")) { Id = 257 }; song = new Song(new LocalizedString("Nebula", ContentLanguageSelection.English)) { Id = 121, SongType = SongType.Original, PVServices = PVServices.Youtube, CreateDate = new DateTime(2012, 6, 1) }; AddSong(song); songWithArtist = new Song(new LocalizedString("Crystal Tears", ContentLanguageSelection.English)) { Id = 7787, FavoritedTimes = 39, CreateDate = new DateTime(2012, 1, 1) }; songWithArtist.AddArtist(artist); AddSong(songWithArtist); queryParams = new SongQueryParams(); search = new Model.Service.Search.SongSearch.SongSearch(querySource, ContentLanguagePreference.Default); }
private void Seed(ISessionFactory sessionFactory) { using (var session = sessionFactory.OpenSession()) using (var tx = session.BeginTransaction()) { Producer = new Artist(TranslatedString.Create("Junk")) { Id = ProducerId }; session.Save(Producer); Producer2 = new Artist(TranslatedString.Create("Junky")); session.Save(Producer2); Producer3 = new Artist(TranslatedString.Create("Keeno")); session.Save(Producer3); var tag = new Tag("Electronic"); session.Save(tag); Song = new Song(new LocalizedString("Nebula", ContentLanguageSelection.English)) { Id = SongId, SongType = SongType.Original, FavoritedTimes = 1, PVServices = PVServices.Youtube, CreateDate = new DateTime(2012, 6, 1) }; Song.Lyrics.Add(new LyricsForSong(Song, ContentLanguageSelection.English, "Here be lyrics", string.Empty)); Song.Tags.Usages.Add(new SongTagUsage(Song, tag)); session.Save(Song); Song2 = new Song(new LocalizedString("Tears of Palm", ContentLanguageSelection.English)) { Id = Song2Id, SongType = SongType.Original, PVServices = PVServices.Youtube, CreateDate = new DateTime(2012, 6, 1) }; Song2.Lyrics.Add(new LyricsForSong(Song2, ContentLanguageSelection.Romaji, "Here be lyrics", string.Empty)); session.Save(Song2); Song3 = new Song(new LocalizedString("Crystal Tears", ContentLanguageSelection.English)) { Id = SongWithArtistId, FavoritedTimes = 39, CreateDate = new DateTime(2012, 1, 1) }; Song3.AddArtist(Producer); session.Save(Song3); Song4 = new Song(new LocalizedString("Azalea", ContentLanguageSelection.English)) { CreateDate = new DateTime(2012, 1, 1) }; Song4.AddArtist(Producer); session.Save(Song4); Song5 = new Song(new LocalizedString("Melancholic", ContentLanguageSelection.English)) { CreateDate = new DateTime(2012, 1, 1) }; Song5.AddArtist(Producer2); session.Save(Song5); Song6 = new Song(new LocalizedString("Tears", ContentLanguageSelection.English)) { CreateDate = new DateTime(2012, 1, 1) }; Song6.AddArtist(Producer3); session.Save(Song6); tx.Commit(); } }
public void SyncArtists_WillNotRemoveExtraArtists() { var link = song.AddArtist("Extra artist", false, ArtistRoles.Composer); var newArtists = new[] { new ArtistContract(artist, ContentLanguagePreference.Default) }; song.SyncArtists(newArtists, ac => new[] { artist }); Assert.AreEqual(2, song.AllArtists.Count, "artists count"); Assert.IsTrue(song.HasArtistLink(link), "Still has the extra artist"); }
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()); }
private ArtistForSong RestoreArtistRef(Song song, Artist artist, ArchivedArtistForSongContract albumRef) { if (artist != null) { return(!artist.HasSong(song) ? artist.AddSong(song, albumRef.IsSupport, albumRef.Roles) : null); } else { return(song.AddArtist(albumRef.NameHint, albumRef.IsSupport, albumRef.Roles)); } }
public void Update_Artists_RemoveDeleted() { repository.Save(vocalist2); repository.Save(song.AddArtist(vocalist2)); vocalist2.Deleted = true; var contract = new SongForEditContract(song, ContentLanguagePreference.English); queries.UpdateBasicProperties(contract); Assert.IsFalse(song.AllArtists.Any(a => Equals(vocalist2, a.Artist)), "vocalist2 was removed from song"); }
public async Task SyncArtists_WillNotRemoveExtraArtists() { var link = song.AddArtist("Extra artist", false, ArtistRoles.Composer); var newArtists = new[] { new ArtistContract(artist, ContentLanguagePreference.Default) }; await song.SyncArtistsAsync(newArtists, ac => Task.FromResult(new List <Artist> { artist })); Assert.AreEqual(2, song.AllArtists.Count, "artists count"); Assert.IsTrue(song.HasArtistLink(link), "Still has the extra artist"); }
public void SetUp() { producer = new Artist(TranslatedString.Create("Tripshots")) { ArtistType = ArtistType.Producer }; vocalist = new Artist(new TranslatedString("初音ミク", "Hatsune Miku", "Hatsune Miku")) { ArtistType = ArtistType.Vocaloid }; song = new Song(new LocalizedString("Nebula", ContentLanguageSelection.English)); song.AddArtist(producer); song.AddArtist(vocalist); song.UpdateArtistString(); album = new Album(new LocalizedString("Synthesis", ContentLanguageSelection.English)); album.AddSong(song, trackNum: 5, discNum: 1); target = new AlbumSongFormatter(new FakeEntryLinkFactory()); }
public async Task Update_Artists_RemoveDeleted() { _repository.Save(_vocalist2); _repository.Save(_song.AddArtist(_vocalist2)); _vocalist2.Deleted = true; var contract = new SongForEditContract(_song, ContentLanguagePreference.English); await _queries.UpdateBasicProperties(contract); _song.AllArtists.Any(a => Equals(_vocalist2, a.Artist)).Should().BeFalse("vocalist2 was removed from song"); }
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 SongContract CreateSong(CreateSongContract contract) { return(HandleTransaction(session => { if (!string.IsNullOrEmpty(contract.BasicData.NicoId)) { var existing = session.Linq <Song>().FirstOrDefault(s => s.NicoId == contract.BasicData.NicoId); if (existing != null) { throw new ServiceException("Song with NicoId '" + contract.BasicData.NicoId + "' has already been added"); } } var song = new Song(new LocalizedString(contract.BasicData.Name), contract.BasicData.NicoId); if (contract.AlbumId != null) { song.AddAlbum(session.Load <Album>(contract.AlbumId.Value), 0); } if (contract.PerformerId != null) { song.AddArtist(session.Load <Artist>(contract.PerformerId.Value)); } if (contract.ProducerId != null) { song.AddArtist(session.Load <Artist>(contract.ProducerId.Value)); } song.UpdateArtistString(); session.Save(song); return new SongContract(song); })); }
public void SetUp() { album = new Album(new LocalizedString("Synthesis", ContentLanguageSelection.English)); producer = new Artist(TranslatedString.Create("Tripshots")) { Id = 1, ArtistType = ArtistType.Producer }; vocalist = new Artist(TranslatedString.Create("Hatsune Miku")) { Id = 39, ArtistType = ArtistType.Vocaloid }; producerContract = new ArtistContract(producer, ContentLanguagePreference.Default); vocalistContract = new ArtistContract(vocalist, ContentLanguagePreference.Default); song1 = new Song(new LocalizedString("Nebula", ContentLanguageSelection.English)) { Id = 2 }; song1.AddArtist(producer); album.AddArtist(producer); album.AddArtist(vocalist); var songInAlbum = new SongInAlbum(song1, album, 1, 1); songInAlbumContract = new SongInAlbumEditContract(songInAlbum, ContentLanguagePreference.Default); songInAlbumContract.Artists = new[] { producerContract }; }
public void MissingRealProducer() { song.AddArtist("devilishP", false, ArtistRoles.Composer); TestValidate(false, song); }
private void AddArtist(Song song, Artist artist) { if (!song.HasArtist(artist)) song.AddArtist(artist); }
private void Seed(ISessionFactory sessionFactory) { using (var session = sessionFactory.OpenSession()) using (var tx = session.BeginTransaction()) { Producer = new Artist(TranslatedString.Create("Junk")) { Id = ProducerId }; session.Save(Producer); Producer2 = new Artist(TranslatedString.Create("Junky")); session.Save(Producer2); Producer3 = new Artist(TranslatedString.Create("Keeno")); session.Save(Producer3); Tag = new Tag("electronic"); session.Save(Tag); Tag2 = new Tag("rock"); Tag2.CreateName("ロック", ContentLanguageSelection.Japanese); session.Save(Tag2); Tag3 = new Tag("alternative rock"); session.Save(Tag3); Tag4 = new Tag("techno"); session.Save(Tag4); Song = new Song(new LocalizedString("Nebula", ContentLanguageSelection.English)) { Id = SongId, SongType = SongType.Original, FavoritedTimes = 1, PVServices = PVServices.Youtube, CreateDate = new DateTime(2012, 6, 1) }; Song.Lyrics.Add(new LyricsForSong(Song, "Here be lyrics", string.Empty, string.Empty, TranslationType.Translation, "en")); var tagUsage = new SongTagUsage(Song, Tag); Song.Tags.Usages.Add(tagUsage); Tag.AllSongTagUsages.Add(tagUsage); session.Save(Song); Song2 = new Song(new LocalizedString("Tears of Palm", ContentLanguageSelection.English)) { Id = Song2Id, SongType = SongType.Original, PVServices = PVServices.Youtube, CreateDate = new DateTime(2012, 6, 1) }; Song2.Lyrics.Add(new LyricsForSong(Song2, "Here be lyrics", string.Empty, string.Empty, TranslationType.Romanized, string.Empty)); session.Save(Song2); Song3 = new Song(new LocalizedString("Crystal Tears", ContentLanguageSelection.English)) { Id = SongWithArtistId, FavoritedTimes = 39, CreateDate = new DateTime(2012, 1, 1) }; Song3.AddArtist(Producer); session.Save(Song3); Song4 = new Song(new LocalizedString("Azalea", ContentLanguageSelection.English)) { CreateDate = new DateTime(2012, 1, 1) }; Song4.AddArtist(Producer); session.Save(Song4); Song5 = new Song(new LocalizedString("Melancholic", ContentLanguageSelection.English)) { CreateDate = new DateTime(2012, 1, 1) }; Song5.AddArtist(Producer2); session.Save(Song5); Song6 = new Song(new LocalizedString("Tears", ContentLanguageSelection.English)) { CreateDate = new DateTime(2012, 1, 1) }; Song6.AddArtist(Producer3); session.Save(Song6); SongWithSpecialChars = new Song(new LocalizedString("Nebula [Extend RMX]", ContentLanguageSelection.English)) { CreateDate = new DateTime(2011, 1, 1) }; session.Save(SongWithSpecialChars); ReleaseEvent = CreateEntry.ReleaseEvent("Miku's birthday"); session.Save(ReleaseEvent); Song.ReleaseEvent = ReleaseEvent; ReleaseEvent.AllSongs.Add(Song); session.Update(Song); UserWithEditPermissions = new User("Miku", "3939", "*****@*****.**", PasswordHashAlgorithms.Default) { GroupId = UserGroupId.Trusted }; session.Save(UserWithEditPermissions); tx.Commit(); } }
public void SetUp() { _producer = CreateEntry.Producer(id: 1, name: "Tripshots"); _vocalist = CreateEntry.Vocalist(id: 39, name: "Hatsune Miku"); _vocalist2 = CreateEntry.Vocalist(id: 40, name: "Kagamine Rin"); _song = CreateEntry.Song(id: 1, name: "Nebula"); _song.LengthSeconds = 39; _repository = new FakeSongRepository(_song); Save(_song.AddArtist(_producer)); Save(_song.AddArtist(_vocalist)); Save(_song.CreatePV(new PVContract { Id = 1, Service = PVService.Youtube, PVId = "hoLu7c2XZYU", Name = "Nebula", PVType = PVType.Original })); _repository.SaveNames(_song); _user = CreateEntry.User(id: 1, name: "Miku"); _user.GroupId = UserGroupId.Trusted; _user2 = CreateEntry.User(id: 2, name: "Rin", email: "*****@*****.**"); _user3 = CreateEntry.User(id: 3, name: "Luka", email: "*****@*****.**"); _repository.Add(_user, _user2); _repository.Add(_producer, _vocalist); _tag = new Tag("vocarock"); _repository.Save(_tag, new Tag("vocaloud")); _releaseEvent = _repository.Save(CreateEntry.ReleaseEvent("Comiket 39")); _permissionContext = new FakePermissionContext(_user); _entryLinkFactory = new EntryAnchorFactory("http://test.vocadb.net"); _newSongContract = new CreateSongContract { SongType = SongType.Original, Names = new[] { new LocalizedStringContract("Resistance", ContentLanguageSelection.English) }, Artists = new[] { new ArtistForSongContract { Artist = new ArtistContract(_producer, ContentLanguagePreference.Default) }, new ArtistForSongContract { Artist = new ArtistContract(_vocalist, ContentLanguagePreference.Default) }, }, PVUrls = new[] { "http://test.vocadb.net/" } }; _pvParser = new FakePVParser(); _pvParser.ResultFunc = (url, getMeta) => VideoUrlParseResult.CreateOk(url, PVService.NicoNicoDouga, "sm393939", getMeta ? VideoTitleParseResult.CreateSuccess("Resistance", "Tripshots", null, "testimg.jpg", 39) : VideoTitleParseResult.Empty); _mailer = new FakeUserMessageMailer(); _queries = new SongQueries( _repository, _permissionContext, _entryLinkFactory, _pvParser, _mailer, new FakeLanguageDetector(), new FakeUserIconFactory(), new EnumTranslations(), new InMemoryImagePersister(), new FakeObjectCache(), new Model.Utils.Config.VdbConfigManager(), new EntrySubTypeNameFactory(), new FollowedArtistNotifier(new FakeEntryLinkFactory(), _mailer, new EnumTranslations(), new EntrySubTypeNameFactory()), new FakeDiscordWebhookNotifier()); }