예제 #1
0
        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 GetUrl_TagOriginalImageMissingFromDisk()
        {
            var tag = CreateEntry.Tag("trance", pictureMime: "image/png");
            var url = urlFactory.GetUrl(tag.Thumb, ImageSize.Original);

            AssertImageFileSystem(url, tag.Thumb, ImageSize.Original, because: "Tag images are always on disk");
        }
예제 #6
0
		public void Update_Discs() {

			var contract = new AlbumForEditContract(album, ContentLanguagePreference.English, new InMemoryImagePersister());
			repository.Save(CreateEntry.AlbumDisc(album));

			contract.Discs = new[] {
				new AlbumDiscPropertiesContract { Id = 1, Name = "Past" },
				new AlbumDiscPropertiesContract { Id = 2, Name = "Present" }
			};

			contract = CallUpdate(contract);

			var albumFromRepo = repository.Load(contract.Id);
			Assert.AreEqual(2, albumFromRepo.Discs.Count, "Number of discs");

			var disc1 = albumFromRepo.GetDisc(1);
			Assert.IsNotNull(disc1, "disc1");
			Assert.AreEqual("Past", disc1.Name, "disc1.Name");

			var disc2 = albumFromRepo.GetDisc(2);
			Assert.IsNotNull(disc2, "disc2");
			Assert.AreEqual("Present", disc2.Name, "disc2.Name");

			var archivedVersion = repository.List<ArchivedAlbumVersion>().FirstOrDefault();

			Assert.IsNotNull(archivedVersion, "Archived version was created");
			Assert.AreEqual(AlbumEditableFields.Discs, archivedVersion.Diff.ChangedFields.Value, "Changed fields");

		}
예제 #7
0
        public void Update_Tracks()
        {
            var contract     = new AlbumForEditContract(album, ContentLanguagePreference.English);
            var existingSong = CreateEntry.Song(name: "Nebula");

            repository.Save(existingSong);

            contract.Songs = new[] {
                CreateSongInAlbumEditContract(1, songId: existingSong.Id),
                CreateSongInAlbumEditContract(2, songName: "Anger")
            };

            contract = CallUpdate(contract);

            var albumFromRepo = repository.Load(contract.Id);

            Assert.AreEqual(2, albumFromRepo.AllSongs.Count, "Number of songs");

            var track1 = albumFromRepo.GetSongByTrackNum(1, 1);

            Assert.AreEqual(existingSong, track1.Song, "First track");

            var track2 = albumFromRepo.GetSongByTrackNum(1, 2);

            Assert.AreEqual("Anger", track2.Song.DefaultName, "Second track name");

            var archivedVersion = repository.List <ArchivedAlbumVersion>().FirstOrDefault();

            Assert.IsNotNull(archivedVersion, "Archived version was created");
            Assert.AreEqual(AlbumEditableFields.Tracks, archivedVersion.Diff.ChangedFields, "Changed fields");
        }
예제 #8
0
        public void SetUp()
        {
            artist     = CreateEntry.Producer(name: "Tripshots");
            vocalist   = CreateEntry.Vocalist(name: "Hatsune Miku");
            repository = new FakeArtistRepository(artist, vocalist);
            var weblink = new ArtistWebLink(artist, "Website", "http://tripshots.net", WebLinkCategory.Official);

            artist.WebLinks.Add(weblink);
            repository.Save(weblink);
            repository.SaveNames(artist, vocalist);

            user = CreateEntry.User(name: "Miku", group: UserGroupId.Moderator);
            repository.Save(user);
            permissionContext = new FakePermissionContext(user);
            imagePersister    = new InMemoryImagePersister();

            queries = new ArtistQueries(repository, permissionContext, new FakeEntryLinkFactory(), imagePersister, imagePersister, MemoryCache.Default,
                                        new FakeUserIconFactory(), new EnumTranslations());

            newArtistContract = new CreateArtistContract {
                ArtistType  = ArtistType.Producer,
                Description = string.Empty,
                Names       = new[] {
                    new LocalizedStringContract("Tripshots", ContentLanguageSelection.English)
                },
                WebLink = new WebLinkContract("http://tripshots.net/", "Website", WebLinkCategory.Official)
            };
        }
예제 #9
0
 public void SetUp()
 {
     user    = repository.Save(CreateEntry.User(group: UserGroupId.Trusted));
     queries = new TagUsageQueries(new FakePermissionContext(user));
     entry   = repository.Save(CreateEntry.Song(name: "Puppet"));
     repository.Save(CreateEntry.Tag("techno"));
 }
예제 #10
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");
        }
예제 #11
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");
        }
예제 #12
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");
        }
예제 #13
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");
        }
예제 #14
0
        public async Task Update_Tracks()
        {
            var contract     = new AlbumForEditContract(_album, ContentLanguagePreference.English, new InMemoryImagePersister());
            var existingSong = CreateEntry.Song(name: "Nebula");

            _repository.Save(existingSong);

            contract.Songs = new[] {
                CreateSongInAlbumEditContract(1, songId: existingSong.Id),
                CreateSongInAlbumEditContract(2, songName: "Anger")
            };

            contract = await CallUpdate(contract);

            var albumFromRepo = _repository.Load(contract.Id);

            albumFromRepo.AllSongs.Count.Should().Be(2, "Number of songs");

            var track1 = albumFromRepo.GetSongByTrackNum(1, 1);

            track1.Song.Should().Be(existingSong, "First track");

            var track2 = albumFromRepo.GetSongByTrackNum(1, 2);

            track2.Song.DefaultName.Should().Be("Anger", "Second track name");

            var archivedVersion = _repository.List <ArchivedAlbumVersion>().FirstOrDefault();

            archivedVersion.Should().NotBeNull("Archived version was created");
            archivedVersion.Diff.ChangedFields.Value.Should().Be(AlbumEditableFields.Tracks, "Changed fields");
        }
예제 #15
0
        public void SetUp()
        {
            artist     = CreateEntry.Producer(name: "Tripshots");
            repository = new FakeArtistRepository(artist);

            foreach (var name in artist.Names)
            {
                repository.Save(name);
            }

            user = CreateEntry.User(name: "Miku");
            repository.Save(user);
            permissionContext = new FakePermissionContext(user);
            imagePersister    = new InMemoryImagePersister();

            queries = new ArtistQueries(repository, permissionContext, new FakeEntryLinkFactory(), imagePersister, imagePersister, MemoryCache.Default);

            newArtistContract = new CreateArtistContract {
                ArtistType  = ArtistType.Producer,
                Description = string.Empty,
                Names       = new[] {
                    new LocalizedStringContract("Tripshots", ContentLanguageSelection.English)
                },
                WebLink = new WebLinkContract("http://tripshots.net/", "Website", WebLinkCategory.Official)
            };
        }
예제 #16
0
        public void Update_Artists()
        {
            var newSong = CreateEntry.Song(name: "Anger");

            repository.Save(newSong);

            foreach (var name in newSong.Names)
            {
                repository.Save(name);
            }

            var contract = new SongForEditContract(newSong, ContentLanguagePreference.English);

            contract.Artists = new [] {
                CreateArtistForSongContract(artistId: producer.Id),
                CreateArtistForSongContract(artistId: vocalist.Id),
                CreateArtistForSongContract(artistName: "Goomeh", roles: ArtistRoles.Vocalist),
            };

            contract = queries.UpdateBasicProperties(contract);

            var songFromRepo = repository.Load(contract.Id);

            Assert.AreEqual(3, songFromRepo.AllArtists.Count, "Number of artists");

            AssertHasArtist(songFromRepo, producer);
            AssertHasArtist(songFromRepo, vocalist);
            Assert.AreEqual("Tripshots feat. Hatsune Miku, Goomeh", songFromRepo.ArtistString.Default, "Artist string");

            var archivedVersion = repository.List <ArchivedSongVersion>().FirstOrDefault();

            Assert.IsNotNull(archivedVersion, "Archived version was created");
            Assert.AreEqual(SongEditableFields.Artists, archivedVersion.Diff.ChangedFields.Value, "Changed fields");
        }
예제 #17
0
        public async Task Update_Artists()
        {
            var newSong = CreateEntry.Song(name: "Anger");

            _repository.Save(newSong);

            foreach (var name in newSong.Names)
            {
                _repository.Save(name);
            }

            var contract = new SongForEditContract(newSong, ContentLanguagePreference.English);

            contract.Artists = new[] {
                CreateArtistForSongContract(artistId: _producer.Id),
                CreateArtistForSongContract(artistId: _vocalist.Id),
                CreateArtistForSongContract(artistName: "Goomeh", roles: ArtistRoles.Vocalist),
            };

            contract = await _queries.UpdateBasicProperties(contract);

            var songFromRepo = _repository.Load(contract.Id);

            songFromRepo.AllArtists.Count.Should().Be(3, "Number of artists");

            AssertHasArtist(songFromRepo, _producer);
            AssertHasArtist(songFromRepo, _vocalist);
            songFromRepo.ArtistString.Default.Should().Be("Tripshots feat. Hatsune Miku, Goomeh", "Artist string");

            var archivedVersion = _repository.List <ArchivedSongVersion>().FirstOrDefault();

            archivedVersion.Should().NotBeNull("Archived version was created");
            archivedVersion.Diff.ChangedFields.Value.Should().Be(SongEditableFields.Artists, "Changed fields");
        }
예제 #18
0
        public void GetRelatedSongs()
        {
            var matchingArtist = Save(CreateEntry.Song());

            Save(matchingArtist.AddArtist(song.Artists.First().Artist));

            Save(song.AddTag(tag).Result);
            var matchingTag = Save(CreateEntry.Song());

            Save(matchingTag.AddTag(tag));

            Save(user.AddSongToFavorites(song, SongVoteRating.Like));
            var matchingLike = Save(CreateEntry.Song());

            Save(user.AddSongToFavorites(matchingLike, SongVoteRating.Like));

            // Unrelated song
            Save(CreateEntry.Song());

            var result = queries.GetRelatedSongs(song.Id, SongOptionalFields.AdditionalNames);

            Assert.IsNotNull(result, "result");
            Assert.AreEqual(1, result.ArtistMatches.Length, "Number of artist matches");
            Assert.AreEqual(matchingArtist.Id, result.ArtistMatches.First().Id, "Matching artist");
            Assert.AreEqual(1, result.TagMatches.Length, "Number of tag matches");
            Assert.AreEqual(matchingTag.Id, result.TagMatches.First().Id, "Matching tag");
            Assert.AreEqual(1, result.LikeMatches.Length, "Number of like matches");
            Assert.AreEqual(matchingLike.Id, result.LikeMatches.First().Id, "Matching like");
        }
예제 #19
0
        public void SetUp()
        {
            sender = new User {
                Name = "Sender user", Id = 1
            };
            receiver = new User {
                Name = "Receiver user", Id = 2
            };
            permissionContext = new FakePermissionContext(new UserWithPermissionsContract(receiver, ContentLanguagePreference.Default));

            var received = sender.SendMessage(receiver, "Hello world", "Message body", false);

            receivedMessage      = received.Item1;
            receivedMessage.Id   = 1;
            receivedMessage.Read = true;
            var sent = receiver.SendMessage(sender, "Hello to you too", "Message body", false);

            sentMessage    = sent.Item1;
            sentMessage.Id = 2;
            var noPermissionMessage = CreateEntry.UserMessageReceived(id: 39, sender: sender, receiver: sender, subject: "Hello world", body: "Message body");

            repository = new FakeUserMessageRepository(sentMessage, sent.Item2, receivedMessage, received.Item2, noPermissionMessage);

            queries = new UserMessageQueries(repository, permissionContext);
        }
예제 #20
0
        public void GetDetails_RecentEvents()
        {
            void AssertContainsEvent(TagDetailsContract details, ReleaseEvent releaseEvent)
            {
                Assert.IsTrue(details.Events.Any(e => e.Id == releaseEvent.Id), "Contains " + releaseEvent);
            }

            var standaloneEvent = CreateEntry.ReleaseEvent("Miku party");
            var otherEvent      = CreateEntry.ReleaseEvent("Magical Mirai");
            var eventSeries     = CreateEntry.EventSeries("VocaTRAVers");
            var seriesUsage     = repository.Save(new EventSeriesTagUsage(eventSeries, tag));

            eventSeries.Tags.Usages.Add(seriesUsage);
            tag.AllEventSeriesTagUsages.Add(seriesUsage);
            var oldSeriesEvent = CreateEntry.ReleaseEvent("VocaTRAVers 1", date: DateTime.Now.AddDays(-30));

            oldSeriesEvent.SetSeries(eventSeries);
            var recentSeriesEvent = CreateEntry.ReleaseEvent("VocaTRAVers 2", date: DateTime.Now);

            recentSeriesEvent.SetSeries(eventSeries);
            repository.Save(standaloneEvent, otherEvent, oldSeriesEvent, recentSeriesEvent);
            repository.Save(eventSeries);
            repository.Save(CreateTagUsage(tag, standaloneEvent), CreateTagUsage(tag, oldSeriesEvent), CreateTagUsage(tag, recentSeriesEvent));

            var result = queries.GetDetails(tag.Id);

            Assert.AreEqual(2, result.EventCount, "EventCount");
            Assert.AreEqual(2, result.Events.Length, "Events.Length");
            Assert.AreEqual(1, result.EventSeriesCount, "EventSeriesCount");
            Assert.AreEqual(1, result.EventSeries.Length, "EventSeries.Length");
            AssertContainsEvent(result, standaloneEvent);
            AssertContainsEvent(result, recentSeriesEvent);
            Assert.IsTrue(result.EventSeries.Any(e => e.Id == eventSeries.Id), "Contains " + eventSeries);
        }
예제 #21
0
        public void GetRelatedSongs()
        {
            var matchingArtist = Save(CreateEntry.Song());

            Save(matchingArtist.AddArtist(_song.Artists.First().Artist));

            Save(_song.AddTag(_tag).Result);
            var matchingTag = Save(CreateEntry.Song());

            Save(matchingTag.AddTag(_tag).Result);

            Save(_user.AddSongToFavorites(_song, SongVoteRating.Like));
            var matchingLike = Save(CreateEntry.Song());

            Save(_user.AddSongToFavorites(matchingLike, SongVoteRating.Like));

            // Unrelated song
            Save(CreateEntry.Song());

            var result = _queries.GetRelatedSongs(_song.Id, SongOptionalFields.AdditionalNames);

            result.Should().NotBeNull("result");
            result.ArtistMatches.Length.Should().Be(1, "Number of artist matches");
            result.ArtistMatches.First().Id.Should().Be(matchingArtist.Id, "Matching artist");
            result.TagMatches.Length.Should().Be(1, "Number of tag matches");
            result.TagMatches.First().Id.Should().Be(matchingTag.Id, "Matching tag");
            result.LikeMatches.Length.Should().Be(1, "Number of like matches");
            result.LikeMatches.First().Id.Should().Be(matchingLike.Id, "Matching like");
        }
예제 #22
0
        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");
        }
예제 #23
0
        public async Task GetDetails_RecentEvents()
        {
            void AssertContainsEvent(TagDetailsContract details, ReleaseEvent releaseEvent)
            {
                details.Stats.Events.Any(e => e.Id == releaseEvent.Id).Should().BeTrue("Contains " + releaseEvent);
            }

            var standaloneEvent = CreateEntry.ReleaseEvent("Miku party");
            var otherEvent      = CreateEntry.ReleaseEvent("Magical Mirai");
            var eventSeries     = CreateEntry.EventSeries("VocaTRAVers");
            var seriesUsage     = _repository.Save(new EventSeriesTagUsage(eventSeries, _tag));

            eventSeries.Tags.Usages.Add(seriesUsage);
            _tag.AllEventSeriesTagUsages.Add(seriesUsage);
            var oldSeriesEvent = CreateEntry.ReleaseEvent("VocaTRAVers 1", date: DateTime.Now.AddDays(-30));

            oldSeriesEvent.SetSeries(eventSeries);
            var recentSeriesEvent = CreateEntry.ReleaseEvent("VocaTRAVers 2", date: DateTime.Now);

            recentSeriesEvent.SetSeries(eventSeries);
            _repository.Save(standaloneEvent, otherEvent, oldSeriesEvent, recentSeriesEvent);
            _repository.Save(eventSeries);
            _repository.Save(CreateTagUsage(_tag, standaloneEvent), CreateTagUsage(_tag, oldSeriesEvent), CreateTagUsage(_tag, recentSeriesEvent));

            var result = await _queries.GetDetailsAsync(_tag.Id);

            result.Stats.EventCount.Should().Be(2, "EventCount");
            result.Stats.Events.Length.Should().Be(2, "Events.Length");
            result.Stats.EventSeriesCount.Should().Be(1, "EventSeriesCount");
            result.Stats.EventSeries.Length.Should().Be(1, "EventSeries.Length");
            AssertContainsEvent(result, standaloneEvent);
            AssertContainsEvent(result, recentSeriesEvent);
            result.Stats.EventSeries.Any(e => e.Id == eventSeries.Id).Should().BeTrue("Contains " + eventSeries);
        }
예제 #24
0
        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.Add(tag, new Tag("vocaloud"));

            releaseEvent = repository.Save(new ReleaseEvent {
                Name = "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)
                    },
                },
                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(), new FakeUserIconFactory(), new EnumTranslations(), new InMemoryImagePersister(), new FakeObjectCache(), new Model.Utils.Config.VdbConfigManager());
        }
예제 #25
0
        public void UpdateAlbumForUser_Add()
        {
            var album = repository.Save(CreateEntry.Album());

            data.UpdateAlbumForUser(userWithEmail.Id, album.Id, PurchaseStatus.Owned, MediaType.PhysicalDisc, 5);

            AssertHasAlbum(userWithEmail, album);
        }
예제 #26
0
        private ReleaseEvent CreateEvent(string name)
        {
            var e = CreateEntry.ReleaseEvent(name, id: _eventId++);

            _querySource.Add(e);

            return(e);
        }
예제 #27
0
 public void SetUp()
 {
     user   = CreateEntry.User();
     folder = new DiscussionFolder("Test folder");
     repo   = new FakeDiscussionFolderRepository(folder);
     repo.Save(user);
     queries = new DiscussionQueries(repo, new FakePermissionContext(user), new FakeUserIconFactory(), new FakeEntryLinkFactory());
 }
        public void CanDelete_Owner_Transitive()
        {
            var song = CreateEntry.Song();

            song.AddArtist(verifiedArtist);

            Assert.IsTrue(CanDelete(verifiedUser, song));
        }
예제 #29
0
        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);
        }
예제 #30
0
        public void CanDelete_Owner_Transitive()
        {
            var song = CreateEntry.Song();

            song.AddArtist(_verifiedArtist);

            CanDelete(_verifiedUser, song).Should().BeTrue();
        }