public void Merge_ToEmpty() { Save(_album.AddArtist(_producer)); Save(_album.AddArtist(_vocalist)); Save(_album.AddSong(_song, 1, 1)); var album2 = CreateEntry.Album(); Save(album2); _queries.Merge(_album.Id, album2.Id); _album.Deleted.Should().BeTrue("Original was deleted"); _album.AllArtists.Count.Should().Be(0, "All artists removed from original"); _album.AllSongs.Count.Should().Be(0, "All songs removed from original"); album2.DefaultName.Should().Be("Synthesis", "Name"); album2.AllArtists.Count.Should().Be(2, "Number of artists"); album2.AllSongs.Count.Should().Be(1, "Number of songs"); album2.AllSongs.First().Song.DefaultName.Should().Be("Nebula"); var mergeRecord = _repository.List <AlbumMergeRecord>().FirstOrDefault(m => m.Source == _album.Id); mergeRecord.Should().NotBeNull("Merge record was created"); mergeRecord.Target.Id.Should().Be(album2.Id, "mergeRecord.Target.Id"); }
public void Merge_ToEmpty() { Save(album.AddArtist(producer)); Save(album.AddArtist(vocalist)); Save(album.AddSong(song, 1, 1)); var album2 = CreateEntry.Album(); Save(album2); queries.Merge(album.Id, album2.Id); Assert.IsTrue(album.Deleted, "Original was deleted"); Assert.AreEqual(0, album.AllArtists.Count, "All artists removed from original"); Assert.AreEqual(0, album.AllSongs.Count, "All songs removed from original"); Assert.AreEqual("Synthesis", album2.DefaultName, "Name"); Assert.AreEqual(2, album2.AllArtists.Count, "Number of artists"); Assert.AreEqual(1, album2.AllSongs.Count, "Number of songs"); Assert.AreEqual("Nebula", album2.AllSongs.First().Song.DefaultName); var mergeRecord = repository.List <AlbumMergeRecord>().FirstOrDefault(m => m.Source == album.Id); Assert.IsNotNull(mergeRecord, "Merge record was created"); Assert.AreEqual(album2.Id, mergeRecord.Target.Id, "mergeRecord.Target.Id"); }
public void GetUrl_AlbumOriginalImageMissing() { var albumContract2 = AlbumContract(CreateEntry.Album(2, "Another Dimensions")); var url = urlFactory.GetUrl(albumContract2, ImageSize.Original); AssertImageDatabase(url, albumContract2, ImageSize.Original, because: "Original album image always loaded from database"); }
public void GetUrl_AlbumOriginalThumbnailMissing() { var albumContract2 = AlbumContract(CreateEntry.Album(2, "Another Dimensions")); var url = urlFactory.GetUrl(albumContract2, ImageSize.Thumb); AssertImageFileSystem(url, albumContract2, ImageSize.Thumb, because: "Missing thumbnail attempted to be loaded from primary location on disk"); }
public void GetUrl_AlbumThumbnailImageExistsInDatabase() { var albumContract2 = AlbumContract(CreateEntry.Album(2, "Another Dimensions", coverPictureMime: "image/png")); var url = urlFactory.GetUrl(albumContract2, ImageSize.Thumb); AssertImageDatabase(url, albumContract2, ImageSize.Thumb, because: "Album thumbnail loaded from database if missing from disk"); }
public void UpdateAlbumForUser_Add() { var album = repository.Save(CreateEntry.Album()); data.UpdateAlbumForUser(userWithEmail.Id, album.Id, PurchaseStatus.Owned, MediaType.PhysicalDisc, 5); AssertHasAlbum(userWithEmail, album); }
public void SetUp() { _producer = CreateEntry.Producer(); _vocalist = CreateEntry.Vocalist(name: "Hatsune Miku"); _vocalist2 = CreateEntry.Vocalist(name: "Rin"); _album = CreateEntry.Album(id: 39, name: "Synthesis"); _repository = new FakeAlbumRepository(_album); foreach (var name in _album.Names) { Save(name); } _user = CreateEntry.User(1, "Miku"); _user.GroupId = UserGroupId.Moderator; _user2 = CreateEntry.User(2, "Luka"); Save(_user, _user2); Save(_producer, _vocalist, _vocalist2); _song = Save(CreateEntry.Song(name: "Nebula")); _song2 = Save(CreateEntry.Song(name: "Anger")); _song3 = Save(CreateEntry.Song(name: "Resistance")); _permissionContext = new FakePermissionContext(_user); var entryLinkFactory = new EntryAnchorFactory("http://test.vocadb.net"); _newAlbumContract = new CreateAlbumContract { DiscType = DiscType.Album, Names = new[] { new LocalizedStringContract("Another Dimensions", ContentLanguageSelection.English) }, Artists = new[] { new ArtistContract(_producer, ContentLanguagePreference.Default), new ArtistContract(_vocalist, ContentLanguagePreference.Default), } }; _imagePersister = new InMemoryImagePersister(); _mailer = new FakeUserMessageMailer(); _queries = new AlbumQueries( _repository, _permissionContext, entryLinkFactory, _imagePersister, _imagePersister, _mailer, new FakeUserIconFactory(), new EnumTranslations(), new FakePVParser(), new FollowedArtistNotifier(new FakeEntryLinkFactory(), new FakeUserMessageMailer(), new EnumTranslations(), new EntrySubTypeNameFactory()), new InMemoryImagePersister(), new FakeObjectCache(), new FakeDiscordWebhookNotifier()); }
public ServerEntryImageFactoryAggregatorTests() { dynamicImageUrlFactory = new FakeDynamicImageUrlFactory(); imageStore = new InMemoryImagePersisterStore(); urlFactory = new ServerEntryImageFactoryAggregator(dynamicImageUrlFactory, new InMemoryEntryThumbPersister(imageStore), new InMemoryEntryImagePersisterOld(imageStore)); var album = CreateEntry.Album(1, coverPictureMime: "image/png"); albumContract = AlbumContract(album); AddImage(albumContract, ImageSize.Thumb); }
public void UpdateAlbumForUser_Delete() { var album = repository.Save(CreateEntry.Album()); data.UpdateAlbumForUser(userWithEmail.Id, album.Id, PurchaseStatus.Owned, MediaType.PhysicalDisc, 5); data.UpdateAlbumForUser(userWithEmail.Id, album.Id, PurchaseStatus.Nothing, MediaType.Other, 0); Assert.IsFalse(userWithEmail.Albums.Any(a => a.Album == album), "Album was removed"); Assert.AreEqual(0, userWithEmail.Albums.Count(), "Number of albums for user"); Assert.AreEqual(0, repository.List <AlbumForUser>().Count, "Number of album links in the repo"); }
public void UpdatePublishDateFromPVs_AlbumReleaseDate() { var album = CreateEntry.Album(); album.OriginalReleaseDate.Year = 2007; album.OriginalReleaseDate.Month = 6; album.OriginalReleaseDate.Day = 1; album.AddSong(song, 1, 1); TestUpdatePublishDateFromPVs(new DateTime(2007, 6, 1), CreatePV(publishDate: new DateTime(2010, 1, 1)) ); }
public void UpdateAlbumForUser_Update() { var album = repository.Save(CreateEntry.Album()); data.UpdateAlbumForUser(userWithEmail.Id, album.Id, PurchaseStatus.Owned, MediaType.PhysicalDisc, 5); data.UpdateAlbumForUser(userWithEmail.Id, album.Id, PurchaseStatus.Owned, MediaType.DigitalDownload, 5); var albumForUser = userWithEmail.Albums.First(a => a.Album == album); Assert.AreEqual(MediaType.DigitalDownload, albumForUser.MediaType, "Media type was updated"); Assert.AreEqual(1, userWithEmail.Albums.Count(), "Number of albums for user"); Assert.AreEqual(1, repository.List <AlbumForUser>().Count, "Number of album links in the repo"); }
public void QueryCatNum() { CreateName(_album, "Synthesis", ContentLanguageSelection.Unspecified); CreateName(_albumWithArtist, "DIVINE", ContentLanguageSelection.Unspecified); _album.OriginalRelease.CatNum = "KRHS-90035"; _albumWithArtist.OriginalRelease.CatNum = "XMCD-1003"; _querySource.Add(CreateEntry.Album(name: "Reverberations")); _queryParams.Common.TextQuery = SearchTextQuery.Create("XMCD-1003"); var result = Find(); result.TotalCount.Should().Be(1, "Total results"); result.Items.Length.Should().Be(1, "1 result"); result.Items.First().Should().Be(_albumWithArtist, "result is expected album"); }
public void Merge_CustomTracks() { Save(_album.AddSong(_song, 1, 1)); Save(_album.AddSong("Bonus song 1", 2, 1)); var album2 = Save(CreateEntry.Album()); Save(album2.AddSong(_song, 1, 1)); Save(album2.AddSong("Bonus song 2", 2, 1)); _queries.Merge(_album.Id, album2.Id); album2.AllSongs.Count.Should().Be(3, "Number of songs for target"); VocaDbAssert.HasSong(album2, _song, 1); VocaDbAssert.HasSong(album2, "Bonus song 2", 2); VocaDbAssert.HasSong(album2, "Bonus song 1", 3); }
public void Merge_CustomTracks() { Save(album.AddSong(song, 1, 1)); Save(album.AddSong("Bonus song 1", 2, 1)); var album2 = Save(CreateEntry.Album()); Save(album2.AddSong(song, 1, 1)); Save(album2.AddSong("Bonus song 2", 2, 1)); queries.Merge(album.Id, album2.Id); Assert.AreEqual(3, album2.AllSongs.Count, "Number of songs for target"); VocaDbAssert.HasSong(album2, song, 1); VocaDbAssert.HasSong(album2, "Bonus song 2", 2); VocaDbAssert.HasSong(album2, "Bonus song 1", 3); }
public void Merge_WithArtists() { Save(_album.AddArtist(_producer, false, ArtistRoles.Instrumentalist)); Save(_album.AddArtist(_vocalist, false, ArtistRoles.Default)); var album2 = Save(CreateEntry.Album()); Save(album2.AddArtist(_vocalist, false, ArtistRoles.Mastering)); Save(album2.AddArtist("Kaito", true, ArtistRoles.Default)); _queries.Merge(_album.Id, album2.Id); _album.AllArtists.Count.Should().Be(1, "Number of artists for source"); // Vocalist was not moved album2.AllArtists.Count.Should().Be(3, "Number of artists for target"); AssertHasArtist(album2, _producer, ArtistRoles.Instrumentalist); AssertHasArtist(album2, _vocalist, ArtistRoles.Mastering); AssertHasArtist(album2, "Kaito", ArtistRoles.Default); }
public void Merge_WithArtists() { Save(album.AddArtist(producer, false, ArtistRoles.Instrumentalist)); Save(album.AddArtist(vocalist, false, ArtistRoles.Default)); var album2 = Save(CreateEntry.Album()); Save(album2.AddArtist(vocalist, false, ArtistRoles.Mastering)); Save(album2.AddArtist("Kaito", true, ArtistRoles.Default)); queries.Merge(album.Id, album2.Id); Assert.AreEqual(1, album.AllArtists.Count, "Number of artists for source"); // Vocalist was not moved Assert.AreEqual(3, album2.AllArtists.Count, "Number of artists for target"); AssertHasArtist(album2, producer, ArtistRoles.Instrumentalist); AssertHasArtist(album2, vocalist, ArtistRoles.Mastering); AssertHasArtist(album2, "Kaito", ArtistRoles.Default); }
public void Merge_WithTracks() { Save(album.AddSong(song, 1, 1)); Save(album.AddSong(song2, 2, 1)); var album2 = Save(CreateEntry.Album()); Save(album2.AddSong(song, 1, 1)); Save(album2.AddSong(song3, 2, 1)); queries.Merge(album.Id, album2.Id); Assert.AreEqual(1, album.AllSongs.Count, "Number of songs for source"); // song was not moved Assert.AreEqual(3, album2.AllSongs.Count, "Number of songs for target"); VocaDbAssert.HasSong(album2, song, 1); VocaDbAssert.HasSong(album2, song2, 3); VocaDbAssert.HasSong(album2, song3, 2); }
public void SetUp() { series = CreateEntry.EventSeries("M3"); existingEvent = new ReleaseEvent(string.Empty, null, series, 2013, "Spring", null, false); repository = new FakeEventRepository(); repository.Save(series); repository.Save(existingEvent); album = CreateEntry.Album(name: "Day's Footsteps"); album.OriginalReleaseEvent = existingEvent; repository.Save(album); user = CreateEntry.User(group: UserGroupId.Trusted); repository.Save(user); permissionContext = new FakePermissionContext(user); queries = new EventQueries(repository, new FakeEntryLinkFactory(), permissionContext, new InMemoryImagePersister()); }
public void Merge_WithTracks() { Save(_album.AddSong(_song, 1, 1)); Save(_album.AddSong(_song2, 2, 1)); var album2 = Save(CreateEntry.Album()); Save(album2.AddSong(_song, 1, 1)); Save(album2.AddSong(_song3, 2, 1)); _queries.Merge(_album.Id, album2.Id); _album.AllSongs.Count.Should().Be(1, "Number of songs for source"); // song was not moved album2.AllSongs.Count.Should().Be(3, "Number of songs for target"); VocaDbAssert.HasSong(album2, _song, 1); VocaDbAssert.HasSong(album2, _song2, 3); VocaDbAssert.HasSong(album2, _song3, 2); }
public void SetUp() { series = CreateEntry.EventSeries("M3"); existingEvent = new ReleaseEvent(string.Empty, null, series, 2013, "Spring"); repository = new FakeEventRepository(); repository.Save(series); repository.Save(existingEvent); album = CreateEntry.Album(name: "Day's Footsteps"); album.OriginalReleaseEventName = "M3 2013 Spring"; repository.Save(album); var user = CreateEntry.User(); repository.Save(user); queries = new EventQueries(repository, new FakeEntryLinkFactory(), new FakePermissionContext(user)); }
public void GetSongForEdit() { var album = _repository.Save(CreateEntry.Album()); album.OriginalRelease.ReleaseDate = new OptionalDateTime(2007, 8, 31); var relEvent = _repository.Save(CreateEntry.ReleaseEvent("Miku's birthday", new DateTime(2007, 8, 31))); album.OriginalRelease.ReleaseEvent = relEvent; album.AddSong(_song, 1, 1); var album2 = _repository.Save(CreateEntry.Album()); album2.OriginalRelease.ReleaseDate = new OptionalDateTime(2017, 8, 31); album2.AddSong(_song, 1, 2); var result = _queries.GetSongForEdit(_song.Id); result.Should().NotBeNull("result"); result.AlbumEventId.Should().Be(relEvent.Id, "AlbumEventId"); }
public void GetSongForEdit() { var album = repository.Save(CreateEntry.Album()); album.OriginalRelease.ReleaseDate = new OptionalDateTime(2007, 8, 31); var relEvent = repository.Save(CreateEntry.ReleaseEvent("Miku's birthday", new DateTime(2007, 8, 31))); album.OriginalRelease.ReleaseEvent = relEvent; album.AddSong(song, 1, 1); var album2 = repository.Save(CreateEntry.Album()); album2.OriginalRelease.ReleaseDate = new OptionalDateTime(2017, 8, 31); album2.AddSong(song, 1, 2); var result = queries.GetSongForEdit(song.Id); Assert.IsNotNull(result, "result"); Assert.AreEqual(relEvent.Id, result.AlbumEventId, "AlbumEventId"); }
public void SetUp() { producer = CreateEntry.Producer(); vocalist = CreateEntry.Vocalist(name: "Hatsune Miku"); vocalist2 = CreateEntry.Vocalist(name: "Rin"); album = CreateEntry.Album(id: 39, name: "Synthesis"); repository = new FakeAlbumRepository(album); foreach (var name in album.Names) { Save(name); } user = CreateEntry.User(1, "Miku"); user.GroupId = UserGroupId.Moderator; user2 = CreateEntry.User(2, "Luka"); Save(user, user2); Save(producer, vocalist, vocalist2); song = Save(CreateEntry.Song(name: "Nebula")); song2 = Save(CreateEntry.Song(name: "Anger")); song3 = Save(CreateEntry.Song(name: "Resistance")); permissionContext = new FakePermissionContext(user); var entryLinkFactory = new EntryAnchorFactory("http://test.vocadb.net"); newAlbumContract = new CreateAlbumContract { DiscType = DiscType.Album, Names = new[] { new LocalizedStringContract("Another Dimensions", ContentLanguageSelection.English) }, Artists = new[] { new ArtistContract(producer, ContentLanguagePreference.Default), new ArtistContract(vocalist, ContentLanguagePreference.Default), } }; imagePersister = new InMemoryImagePersister(); mailer = new FakeUserMessageMailer(); queries = new AlbumQueries(repository, permissionContext, entryLinkFactory, imagePersister, imagePersister, mailer, new FakeUserIconFactory(), new EnumTranslations(), new FakePVParser()); }
public void SetUp() { series = CreateEntry.EventSeries("M3"); existingEvent = CreateEntry.SeriesEvent(series, 2013, "Spring"); series.AllEvents.Add(existingEvent); repository = new FakeEventRepository(); repository.Save(series); repository.Save(existingEvent); repository.SaveNames(series); repository.SaveNames(existingEvent); album = CreateEntry.Album(name: "Day's Footsteps"); album.OriginalReleaseEvent = existingEvent; repository.Save(album); user = CreateEntry.User(group: UserGroupId.Trusted); repository.Save(user); permissionContext = new FakePermissionContext(user); queries = new EventQueries(repository, new FakeEntryLinkFactory(), permissionContext, new InMemoryImagePersister(), new FakeUserIconFactory(), new EnumTranslations(), mailer); }
public void ClearRatings() { userWithEmail.AdditionalPermissions.Add(PermissionToken.DisableUsers); RefreshLoggedUser(); var album = CreateEntry.Album(); var song = CreateEntry.Song(); repository.Save(album); repository.Save(song); repository.Save(userWithoutEmail.AddAlbum(album, PurchaseStatus.Nothing, MediaType.DigitalDownload, 5)); repository.Save(userWithoutEmail.AddSongToFavorites(song, SongVoteRating.Favorite)); data.ClearRatings(userWithoutEmail.Id); Assert.AreEqual(0, userWithoutEmail.AllAlbums.Count, "No albums for user"); Assert.AreEqual(0, userWithoutEmail.FavoriteSongs.Count, "No songs for user"); Assert.AreEqual(0, album.UserCollections.Count, "Number of users for the album"); Assert.AreEqual(0, song.UserFavorites.Count, "Number of users for the song"); Assert.AreEqual(0, album.RatingTotal, "Album RatingTotal"); Assert.AreEqual(0, song.RatingScore, "Song RatingScore"); }
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); }