Esempio n. 1
0
        private void ArchiveSong(IRepositoryContext <Song> ctx, Song song, SongDiff diff, SongArchiveReason reason, string notes = "")
        {
            var agentLoginData = ctx.CreateAgentLoginData(PermissionContext);
            var archived       = ArchivedSongVersion.Create(song, diff, agentLoginData, reason, notes);

            ctx.OfType <ArchivedSongVersion>().Save(archived);
        }
Esempio n. 2
0
        public void Archive(ISession session, Song song, SongDiff diff, SongArchiveReason reason, string notes = "")
        {
            var agentLoginData = SessionHelper.CreateAgentLoginData(session, PermissionContext);
            var archived       = ArchivedSongVersion.Create(song, diff, agentLoginData, reason, notes);

            session.Save(archived);
        }
Esempio n. 3
0
        public ArchivedSongVersion Archive(IDatabaseContext <Song> ctx, Song song, SongDiff diff, SongArchiveReason reason, string notes = "")
        {
            var agentLoginData = ctx.CreateAgentLoginData(PermissionContext);
            var archived       = ArchivedSongVersion.Create(song, diff, agentLoginData, reason, notes);

            ctx.OfType <ArchivedSongVersion>().Save(archived);
            return(archived);
        }
Esempio n. 4
0
        private async Task <ArchivedSongVersion> ArchiveSongAsync(IDatabaseContext <Song> ctx, Song song, SongDiff diff, SongArchiveReason reason, string notes = "")
        {
            var agentLoginData = await ctx.CreateAgentLoginDataAsync(PermissionContext);

            var archived = ArchivedSongVersion.Create(song, diff, agentLoginData, reason, notes);
            await ctx.OfType <ArchivedSongVersion>().SaveAsync(archived);

            return(archived);
        }
Esempio n. 5
0
        public void CreateReport_Notify_ReportTypeNameAndNotes()
        {
            var editor = user2;

            repository.Save(ArchivedSongVersion.Create(song, new SongDiff(), new AgentLoginData(editor), SongArchiveReason.PropertiesUpdated, String.Empty));
            queries.CreateReport(song.Id, SongReportType.BrokenPV, "39.39.39.39", "It's Miku, not Rin", null);

            var entryLink = MarkdownHelper.CreateMarkdownLink(entryLinkFactory.GetFullEntryUrl(song), song.DefaultName);

            var notification = repository.List <UserMessage>().FirstOrDefault();

            Assert.IsNotNull(notification, "notification was created");
            Assert.AreEqual(string.Format(EntryReportStrings.EntryVersionReportTitle, song.DefaultName), notification.Subject, "Notification subject");
            Assert.AreEqual(string.Format(EntryReportStrings.EntryVersionReportBody, entryLink, "Broken PV (It's Miku, not Rin)"), notification.Message, "Notification body");
        }
Esempio n. 6
0
        public void CreateReport_DoNotNotifyIfAmbiguous()
        {
            repository.Save(ArchivedSongVersion.Create(song, new SongDiff(), new AgentLoginData(user2), SongArchiveReason.PropertiesUpdated, String.Empty));
            repository.Save(ArchivedSongVersion.Create(song, new SongDiff(), new AgentLoginData(user3), SongArchiveReason.PropertiesUpdated, String.Empty));
            queries.CreateReport(song.Id, SongReportType.Other, "39.39.39.39", "It's Miku, not Rin", null);

            var report = repository.List <SongReport>().First();

            Assert.AreEqual(song, report.Entry, "Report was created for song");
            Assert.IsNull(report.Version, "Version");

            var notification = repository.List <UserMessage>().FirstOrDefault();

            Assert.IsNull(notification, "notification was not created");
        }
Esempio n. 7
0
        public void CreateReport_DoNotNotifyIfAmbiguous()
        {
            _repository.Save(ArchivedSongVersion.Create(_song, new SongDiff(), new AgentLoginData(_user2), SongArchiveReason.PropertiesUpdated, String.Empty));
            _repository.Save(ArchivedSongVersion.Create(_song, new SongDiff(), new AgentLoginData(_user3), SongArchiveReason.PropertiesUpdated, String.Empty));
            _queries.CreateReport(_song.Id, SongReportType.Other, "39.39.39.39", "It's Miku, not Rin", null);

            var report = _repository.List <SongReport>().First();

            report.Entry.Should().Be(_song, "Report was created for song");
            report.Version.Should().BeNull("Version");

            var notification = _repository.List <UserMessage>().FirstOrDefault();

            notification.Should().BeNull("notification was not created");
        }
Esempio n. 8
0
        public void CreateReport_NotifyIfUnambiguous()
        {
            var editor = user2;

            repository.Save(ArchivedSongVersion.Create(song, new SongDiff(), new AgentLoginData(editor), SongArchiveReason.PropertiesUpdated, String.Empty));
            queries.CreateReport(song.Id, SongReportType.Other, "39.39.39.39", "It's Miku, not Rin", null);

            var report = repository.List <SongReport>().First();

            Assert.AreEqual(song, report.Entry, "Report was created for song");
            Assert.IsNull(report.Version, "Version");

            var notification = repository.List <UserMessage>().FirstOrDefault();

            Assert.IsNotNull(notification, "notification was created");
            Assert.AreEqual(editor, notification.Receiver, "notification was receiver is editor");
            Assert.AreEqual(string.Format(EntryReportStrings.EntryVersionReportTitle, song.DefaultName), notification.Subject, "Notification subject");
        }
Esempio n. 9
0
        public void CreateReport_NotifyIfUnambiguous()
        {
            var editor = _user2;

            _repository.Save(ArchivedSongVersion.Create(_song, new SongDiff(), new AgentLoginData(editor), SongArchiveReason.PropertiesUpdated, String.Empty));
            _queries.CreateReport(_song.Id, SongReportType.Other, "39.39.39.39", "It's Miku, not Rin", null);

            var report = _repository.List <SongReport>().First();

            report.Entry.Should().Be(_song, "Report was created for song");
            report.Version.Should().BeNull("Version");

            var notification = _repository.List <UserMessage>().FirstOrDefault();

            notification.Should().NotBeNull("notification was created");
            notification.Receiver.Should().Be(editor, "notification was receiver is editor");
            notification.Subject.Should().Be(string.Format(EntryReportStrings.EntryVersionReportTitle, _song.DefaultName), "Notification subject");
        }
Esempio n. 10
0
        public void CreateReport_Version()
        {
            var version = ArchivedSongVersion.Create(_song, new SongDiff(), new AgentLoginData(_user), SongArchiveReason.PropertiesUpdated, String.Empty);

            _repository.Save(version);
            CallCreateReport(SongReportType.Other, version.Version);

            var report = _repository.List <SongReport>().First();

            report.VersionNumber.Should().Be(version.Version, "Version number");
            report.VersionBase.Should().NotBeNull("VersionBase");

            var notification = _repository.List <UserMessage>().FirstOrDefault();

            notification.Should().NotBeNull("Notification was created");
            notification.Receiver.Should().Be(_user, "Notification receiver");
            notification.Subject.Should().Be(string.Format(EntryReportStrings.EntryVersionReportTitle, _song.DefaultName), "Notification subject");
            notification.Message.Should().Be(string.Format(EntryReportStrings.EntryVersionReportBody, MarkdownHelper.CreateMarkdownLink(_entryLinkFactory.GetFullEntryUrl(_song), _song.DefaultName), "It's Miku, not Rin"), "Notification message");
        }
Esempio n. 11
0
        public void CreateReport_Version()
        {
            var version = ArchivedSongVersion.Create(song, new SongDiff(), new AgentLoginData(user), SongArchiveReason.PropertiesUpdated, String.Empty);

            repository.Save(version);
            queries.CreateReport(song.Id, SongReportType.Other, "39.39.39.39", "It's Miku, not Rin", version.Version);

            var report = repository.List <SongReport>().First();

            Assert.AreEqual(version.Version, report.VersionNumber, "Version number");
            Assert.IsNotNull(report.VersionBase, "VersionBase");

            var notification = repository.List <UserMessage>().FirstOrDefault();

            Assert.IsNotNull(notification, "Notification was created");
            Assert.AreEqual(user, notification.Receiver, "Notification receiver");
            Assert.AreEqual(string.Format(EntryReportStrings.EntryVersionReportTitle, song.DefaultName), notification.Subject, "Notification subject");
            Assert.AreEqual(string.Format(EntryReportStrings.EntryVersionReportBody,
                                          MarkdownHelper.CreateMarkdownLink(entryLinkFactory.GetFullEntryUrl(song), song.DefaultName), "It's Miku, not Rin"),
                            notification.Message, "Notification message");
        }