コード例 #1
0
ファイル: SaveTests.cs プロジェクト: Nikismyname/Momento
        public void SaveShouldThrowIdLinesToBeUpdatedsIdsDoNoteBelongTheGivenNote()
        {
            const int NonExistantCodeLineId = 42;

            UserS.SeedPeshoAndGosho(this.context);
            var note      = NoteS.SeedNoteToUser(UserS.PeshoId, this.context);
            var codeLines = NoteS.SeedTwoCodeLinesToNote(note, this.context);

            var editInput = new NoteEdit
            {
                Id    = note.Id,
                Lines = new HashSet <CodeLineEdit>
                {
                    new CodeLineEdit
                    {
                        Id = codeLines[0].Id,
                    },
                    new CodeLineEdit
                    {
                        Id = NonExistantCodeLineId,
                    }
                }
            };

            Action action = () => this.noteService.Save(editInput, UserS.PeshoUsername);

            action.Should().Throw <AccessDenied>().WithMessage("The Lines you are trying to edit do not belong the Note you are editing!");
        }
コード例 #2
0
ファイル: SaveTests.cs プロジェクト: Nikismyname/Momento
        public void SaveShouldDeleteRemovedCodeLines()
        {
            const bool   newEditorMode         = true;
            const bool   newVisible            = true;
            const int    line1newInpageId      = 42;
            const string line1NewNoteContent   = "line one new note content";
            const int    line1newOrder         = 44;
            const string line1NewSourceContent = "line one new source content";

            UserS.SeedPeshoAndGosho(this.context);
            var note      = NoteS.SeedNoteToUser(UserS.PeshoId, this.context);
            var codeLines = NoteS.SeedTwoCodeLinesToNote(note, this.context);

            var editInput = new NoteEdit
            {
                Id    = note.Id,
                Lines = new HashSet <CodeLineEdit>
                {
                    new CodeLineEdit
                    {
                        Id            = codeLines[0].Id,
                        EditorMode    = newEditorMode,
                        InPageId      = line1newInpageId,
                        NoteContent   = line1NewNoteContent,
                        Order         = line1newOrder,
                        SourceContent = line1NewSourceContent,
                        Visible       = newVisible,
                    },
                }
            };

            Action action = () => this.noteService.Save(editInput, UserS.PeshoUsername);

            action.Invoke();

            ///Since it is passed back from the edit model it is not deleted
            codeLines[0].IsDeleted.Should().Be(false);
            ///Since it is not passed back it is understood it should be deleted
            codeLines[1].IsDeleted.Should().Be(true);
        }
コード例 #3
0
ファイル: SaveTests.cs プロジェクト: Nikismyname/Momento
        public void SaveShouldUpdateExistionCodeLines()
        {
            const bool   newEditorMode         = true;
            const bool   newVisible            = true;
            const int    line1newInpageId      = 42;
            const int    line2newInpageId      = 43;
            const string line1NewNoteContent   = "line one new note content";
            const string line2NewNoteContent   = "line two new note content";
            const int    line1newOrder         = 44;
            const int    line2newOrder         = 45;
            const string line1NewSourceContent = "line one new source content";
            const string line2NewSourceContent = "line two new source content";

            UserS.SeedPeshoAndGosho(this.context);
            var note      = NoteS.SeedNoteToUser(UserS.PeshoId, this.context);
            var codeLines = NoteS.SeedTwoCodeLinesToNote(note, this.context);

            var editInput = new NoteEdit
            {
                Id    = note.Id,
                Lines = new HashSet <CodeLineEdit>
                {
                    new CodeLineEdit
                    {
                        Id            = codeLines[0].Id,
                        EditorMode    = newEditorMode,
                        InPageId      = line1newInpageId,
                        NoteContent   = line1NewNoteContent,
                        Order         = line1newOrder,
                        SourceContent = line1NewSourceContent,
                        Visible       = newVisible,
                    },
                    new CodeLineEdit
                    {
                        Id            = codeLines[1].Id,
                        EditorMode    = newEditorMode,
                        InPageId      = line2newInpageId,
                        NoteContent   = line2NewNoteContent,
                        Order         = line2newOrder,
                        SourceContent = line2NewSourceContent,
                        Visible       = newVisible,
                    },
                }
            };

            Action action = () => this.noteService.Save(editInput, UserS.PeshoUsername);

            action.Invoke();

            codeLines[0].EditorMode.Should().Be(newEditorMode);
            codeLines[0].InPageId.Should().Be(line1newInpageId);
            codeLines[0].NoteContent.Should().Be(line1NewNoteContent);
            codeLines[0].Order.Should().Be(line1newOrder);
            codeLines[0].SourceContent.Should().Be(line1NewSourceContent);
            codeLines[0].Visible.Should().Be(newVisible);

            //codeLines[1].EditorMode.Should().Be(newEditorMode);
            //codeLines[1].InPageId.Should().Be(line2newInpageId);
            //codeLines[1].NoteContent.Should().Be(line2NewNoteContent);
            //codeLines[1].Order.Should().Be(line2newOrder);
            //codeLines[1].SourceContent.Should().Be(line2NewSourceContent);
            //codeLines[1].Visible.Should().Be(newVisible);
        }