Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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.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()));
        }
Exemplo n.º 4
0
        private ReleaseEvent CreateEvent(string name)
        {
            var e = CreateEntry.ReleaseEvent(name, id: _eventId++);

            _querySource.Add(e);

            return(e);
        }
Exemplo n.º 5
0
        public void UpdateEventForUser()
        {
            var releaseEvent = repository.Save(CreateEntry.ReleaseEvent("Miku land"));

            data.UpdateEventForUser(userWithEmail.Id, releaseEvent.Id, UserEventRelationshipType.Attending);

            var link = userWithEmail.Events.FirstOrDefault(e => e.ReleaseEvent == releaseEvent);

            Assert.IsNotNull(link, "Event was added for user");
            Assert.AreEqual(UserEventRelationshipType.Attending, link.RelationshipType, "Link relationship type");
        }
Exemplo n.º 6
0
        public void Update_ChangeToSeriesEvent()
        {
            var releaseEvent = repository.Save(CreateEntry.ReleaseEvent("M3 39"));
            var contract     = Contract(releaseEvent);

            contract.Series = new ReleaseEventSeriesContract(series, ContentLanguagePreference.Default);

            queries.Update(contract, null);

            Assert.AreEqual(series, releaseEvent.Series, "Series");
            Assert.IsTrue(series.AllEvents.Contains(releaseEvent), "Series contains event");
        }
Exemplo n.º 7
0
        public void Update_ChangeName_DuplicateForSameEvent()
        {
            var releaseEvent = repository.Save(CreateEntry.ReleaseEvent("Comiket 39"));
            var contract     = new ReleaseEventForEditContract(releaseEvent, ContentLanguagePreference.Default, permissionContext, null)
            {
                Names = new[] {
                    new LocalizedStringWithIdContract {
                        Value = "Comiket 39"
                    },
                    new LocalizedStringWithIdContract {
                        Value = "Comiket 39"
                    }
                }
            };

            queries.Update(contract, null);
        }
Exemplo n.º 8
0
        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");
        }
Exemplo n.º 9
0
        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");
        }
Exemplo n.º 10
0
        public void Update_ReleaseEvent_Change()
        {
            context.RunTest(repository => {
                var queries = Queries(repository);

                var newEvent = repository.HandleTransaction(ctx => new ReleaseEventContract(ctx.Save(CreateEntry.ReleaseEvent("Mikumas")), false));

                // Act
                var contract = new SongForEditContract(Db.Song, ContentLanguagePreference.English)
                {
                    ReleaseEvent = newEvent
                };

                var updated = queries.UpdateBasicProperties(contract);

                // Assert
                Assert.AreEqual(newEvent.Id, updated.ReleaseEvent?.Id, "Release event was changed");
                var releaseEvent = repository.HandleQuery(ctx => ctx.Load <ReleaseEvent>(newEvent.Id));
                Assert.AreEqual(1, releaseEvent.AllSongs.Count, "Song was added to event");
            });
        }
Exemplo n.º 11
0
        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();
                }
        }