public void Delete_IsSuccessful() { var note = NoteTestHelper.CreateNote(new NoteOptions()); note.Delete(); note.PopUncommittedEvents().Have <NoteDeletedEvent>(); }
public void ChangeVisibility_DraftNote_NotApplyChange() { var note = NoteTestHelper.CreateNote(new NoteOptions()); note.ChangeVisibility(Visibility.Public); note.PopUncommittedEvents().NotHave <NoteVisibilityChangedEvent>(); }
private static Comment CreateDefaultComment() { var note = NoteTestHelper.CreateNote(new NoteOptions { Status = NoteStatus.Published }); return(note.AddComment(Guid.NewGuid(), "comment text")); }
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))); }
public void Create_NotCloneNote_ThrowEx() { var note = NoteTestHelper.CreateNote(new NoteOptions()); Assert.Throws <OnlyCloneNoteCanBeMergedException>(() => note.CreateMergeRequest(_mockNoteChecker.Object, _mockMergeRequestChecker.Object, _userId, "title", "description")); }
public void Clone_DraftNote_ThrowEx() { var note = NoteTestHelper.CreateNote(new NoteOptions { Status = NoteStatus.Draft }); Assert.Throws <NoteHaveNotBeenPublishedException>(() => note.Clone(_userId, Guid.NewGuid())); }
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"); }
public void Publish_IsSuccessful() { var note = NoteTestHelper.CreateNote(new NoteOptions { Status = NoteStatus.Draft }); note.Publish(); note.PopUncommittedEvents().Have <NotePublishedEvent>(); }
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"); }
public void Publish_HasBeenDeleted_ThrowEx() { var note = NoteTestHelper.CreateNote(new NoteOptions { Status = NoteStatus.Draft }); note.Delete(); Assert.Throws <NoteHasBeenDeletedException>(() => note.Publish()); }
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); }
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))); }
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); }
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); }
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); }
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)); }
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")); }
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"); }
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); } }
private Note CreateCloneNote() { var note = NoteTestHelper.CreateNote(new NoteOptions()); return(note.Clone(_userId, Guid.NewGuid())); }