Example #1
0
    public void Delete_IsSuccessful()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions());

        note.Delete();
        note.PopUncommittedEvents().Have <NoteDeletedEvent>();
    }
Example #2
0
    public void ChangeVisibility_DraftNote_NotApplyChange()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions());

        note.ChangeVisibility(Visibility.Public);

        note.PopUncommittedEvents().NotHave <NoteVisibilityChangedEvent>();
    }
Example #3
0
    private static Comment CreateDefaultComment()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions {
            Status = NoteStatus.Published
        });

        return(note.AddComment(Guid.NewGuid(), "comment text"));
    }
Example #4
0
    public void Delete_HasBeenDeleted_OnlyApplyChangeOnce()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions());

        note.Delete();
        note.Delete();
        Assert.NotNull(note.PopUncommittedEvents().SingleOrDefault(e => e.GetType() == typeof(NoteDeletedEvent)));
    }
Example #5
0
    public void Create_NotCloneNote_ThrowEx()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions());

        Assert.Throws <OnlyCloneNoteCanBeMergedException>(() =>
                                                          note.CreateMergeRequest(_mockNoteChecker.Object, _mockMergeRequestChecker.Object, _userId, "title",
                                                                                  "description"));
    }
Example #6
0
    public void Clone_DraftNote_ThrowEx()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions {
            Status = NoteStatus.Draft
        });

        Assert.Throws <NoteHaveNotBeenPublishedException>(() => note.Clone(_userId, Guid.NewGuid()));
    }
Example #7
0
        public void Note_Fetch_Info_List()
        {
            NoteTestHelper.NoteAdd();
            NoteTestHelper.NoteAdd();

            var notes = NoteRepository.NoteFetchInfoList(new NoteDataCriteria());

            Assert.IsTrue(notes.Count() > 1, "Row returned should be greater than one");
        }
Example #8
0
    public void Publish_IsSuccessful()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions {
            Status = NoteStatus.Draft
        });

        note.Publish();
        note.PopUncommittedEvents().Have <NotePublishedEvent>();
    }
Example #9
0
        public void Note_Fetch()
        {
            var note = NoteTestHelper.NoteNew();

            note = NoteRepository.NoteSave(note);

            note = NoteRepository.NoteFetch(note.NoteId);

            Assert.IsTrue(note != null, "Row returned should not equal null");
        }
Example #10
0
    public void Publish_HasBeenDeleted_ThrowEx()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions {
            Status = NoteStatus.Draft
        });

        note.Delete();

        Assert.Throws <NoteHasBeenDeletedException>(() => note.Publish());
    }
Example #11
0
    public void Edit_IsSuccessful()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions());

        note.Edit(_userId, "Java", "Java content", "comment");

        var noteEditedEvent = note.PopUncommittedEvents().Have <NoteEditedEvent>();

        Assert.Equal("Java", noteEditedEvent.Title);
        Assert.Equal("Java content", noteEditedEvent.Content);
    }
Example #12
0
    public void Publish_HasBeenPublished_OnlyApplyChangeOnce()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions {
            Status = NoteStatus.Draft
        });

        note.Publish();
        note.Publish();

        Assert.NotNull(note.PopUncommittedEvents().SingleOrDefault(e => e.GetType() == typeof(NotePublishedEvent)));
    }
Example #13
0
        public void Note_Add()
        {
            var note = NoteTestHelper.NoteNew();

            Assert.IsTrue(note.IsValid, "IsValid should be true");

            note = NoteRepository.NoteSave(note);

            Assert.IsTrue(note.NoteId != 0, "NoteId should be a non-zero value");

            NoteRepository.NoteFetch(note.NoteId);
        }
Example #14
0
    public void ChangeVisibility_IsSuccessful()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions {
            Status = NoteStatus.Published
        });

        note.ChangeVisibility(Visibility.Private);

        var noteVisibilityChangedEvent = note.PopUncommittedEvents().Have <NoteVisibilityChangedEvent>();

        Assert.Equal(Visibility.Private, noteVisibilityChangedEvent.Visibility);
    }
Example #15
0
    public void Clone_IsSuccessful()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions());

        var cloneNote = note.Clone(_userId, Guid.NewGuid());

        var noteCreatedEvent = cloneNote.PopUncommittedEvents().Have <NoteCreatedEvent>();

        Assert.Equal(note.Id, noteCreatedEvent.CloneFormId);
        Assert.Equal(cloneNote.Id, noteCreatedEvent.AggregateId);
        Assert.Equal(_userId, noteCreatedEvent.CreatorId);
        Assert.Equal(NoteStatus.Published, noteCreatedEvent.Status);
    }
Example #16
0
    public void UpdateTags_IsSuccessful()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions());

        var tags = new List <string> {
            "cqrs", "ddd"
        };

        note.UpdateTags(tags);

        var noteTagsUpdatedEvent = note.PopUncommittedEvents().Have <NoteTagsUpdatedEvent>();

        Assert.True(noteTagsUpdatedEvent.Tags.SequenceEqual(tags));
    }
Example #17
0
    public void AddComment_WithNote_IsSuccessful()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions {
            Status = NoteStatus.Published
        });

        var comment = note.AddComment(Guid.NewGuid(), "comment text");

        var @event = comment.PopUncommittedEvents().Have <CommentCreatedEvent>();

        Assert.Equal(nameof(Note), @event.EntityType);
        Assert.Equal(note.Id.ToString(), @event.EntityId);
        Assert.Equal("comment text", @event.Text);
        Assert.Null(@event.RepliedCommentId);
    }
    public static MergeRequest CreateOpenMergeRequest()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions());

        var cloneNote = note.Clone(Guid.NewGuid(), Guid.NewGuid());

        var noteChecker = new Mock <INoteChecker>();

        noteChecker.Setup(n => n.IsPublishedNote(It.IsAny <Guid>())).Returns(true);

        var mergeRequestChecker = new Mock <IMergeRequestChecker>();

        mergeRequestChecker.Setup(n => n.HasOpenMergeRequest(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(false);

        return(cloneNote.CreateMergeRequest(noteChecker.Object, mergeRequestChecker.Object, Guid.NewGuid(), "title",
                                            "description"));
    }
Example #19
0
        public void Note_Edit()
        {
            var note = NoteTestHelper.NoteNew();

            var name = note.Body;

            Assert.IsTrue(note.IsValid, "IsValid should be true");

            note = NoteRepository.NoteSave(note);

            note = NoteRepository.NoteFetch(note.NoteId);

            note.Body = DataHelper.RandomString(20);

            note = NoteRepository.NoteSave(note);

            note = NoteRepository.NoteFetch(note.NoteId);

            Assert.IsTrue(note.Body != name, "Body should have different value");
        }
Example #20
0
        public void Note_Delete()
        {
            var note = NoteTestHelper.NoteNew();

            Assert.IsTrue(note.IsValid, "IsValid should be true");

            note = NoteRepository.NoteSave(note);

            note = NoteRepository.NoteFetch(note.NoteId);

            NoteRepository.NoteDelete(note.NoteId);

            try
            {
                NoteRepository.NoteFetch(note.NoteId);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.GetBaseException() is InvalidOperationException);
            }
        }
Example #21
0
    private Note CreateCloneNote()
    {
        var note = NoteTestHelper.CreateNote(new NoteOptions());

        return(note.Clone(_userId, Guid.NewGuid()));
    }