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 Update_ReleaseEvent_NewEvent_SeriesEvent()
        {
            var series   = repository.Save(CreateEntry.EventSeries("Comiket"));
            var contract = EditContract();

            contract.ReleaseEvent = new ReleaseEventContract {
                Name = "Comiket 40"
            };

            queries.UpdateBasicProperties(contract);

            Assert.IsNotNull(song.ReleaseEvent, "ReleaseEvent");
            Assert.AreEqual(series, song.ReleaseEvent.Series, "Series");
            Assert.AreEqual(40, song.ReleaseEvent.SeriesNumber, "SeriesNumber");
        }
Exemplo n.º 4
0
        public async Task Update_ReleaseEvent_NewEvent_SeriesEvent()
        {
            var series   = _repository.Save(CreateEntry.EventSeries("Comiket"));
            var contract = EditContract();

            contract.ReleaseEvent = new ReleaseEventContract {
                Name = "Comiket 40"
            };

            await _queries.UpdateBasicProperties(contract);

            _song.ReleaseEvent.Should().NotBeNull("ReleaseEvent");
            _song.ReleaseEvent.Series.Should().Be(series, "Series");
            _song.ReleaseEvent.SeriesNumber.Should().Be(40, "SeriesNumber");
        }
Exemplo n.º 5
0
        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());
        }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        public void UpdateSeries_DuplicateName()
        {
            var series2 = repository.SaveWithNames <ReleaseEventSeries, EventSeriesName>(CreateEntry.EventSeries("M3.9"));

            repository.SaveWithNames <ReleaseEvent, EventName>(CreateEntry.SeriesEvent(series2, 2013, "Spring"));

            var contract = new ReleaseEventSeriesForEditContract(series, ContentLanguagePreference.English);

            contract.Names[0].Value = "M3.9";

            queries.UpdateSeries(contract, null);
        }
Exemplo n.º 9
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");
                    ReleaseEvent.CreateName("ミク誕生祭", ContentLanguageSelection.Japanese);
                    session.Save(ReleaseEvent);
                    Song.ReleaseEvent = ReleaseEvent;
                    ReleaseEvent.AllSongs.Add(Song);
                    session.Update(Song);

                    ReleaseEventSeries = CreateEntry.EventSeries("Comiket");
                    session.Save(ReleaseEventSeries);

                    ReleaseEvent2 = CreateEntry.SeriesEvent(ReleaseEventSeries, 39);
                    session.Save(ReleaseEvent2);

                    UserWithEditPermissions = new User("Miku", "3939", "*****@*****.**", PasswordHashAlgorithms.Default)
                    {
                        GroupId = UserGroupId.Trusted
                    };
                    session.Save(UserWithEditPermissions);

                    tx.Commit();
                }
        }