private async Task GivenEdited2TimesNote() { _editNoteCommandForRestore = new EditNoteCommand(_noteId, ".Net 7", ".Net 7 new feature", ""); //v2 await _mediator.Send(_editNoteCommandForRestore); //v3 await _mediator.Send(new EditNoteCommand(_noteId, ".Net 8", ".Net 8 new feature", "")); _noteHistories = await _noteQuery.GetHistoriesAsync(_noteId); }
private async Task ThenTheSourceNoteShouldBeUpdated() { var note = await _noteQuery.GetNoteAsync(_noteId); Assert.Equal(2, note.Version); Assert.Equal(_editNoteCommand.Title, note.Title); Assert.Equal(_editNoteCommand.Content, note.Content); var noteHistories = await _noteQuery.GetHistoriesAsync(note.Id); Assert.Equal(2, noteHistories.Count()); }
public async Task Create_IsSuccessful(NoteStatus status) { var spaceId = await _fixture.GetOrCreateDefaultSpaceAsync(); var command = new CreateNoteCommand { SpaceId = spaceId, Title = ".Net 6", Content = ".Net 6 new feature", Status = status }; var noteId = await _mediator.Send(command); var note = await _noteQuery.GetNoteAsync(noteId); Assert.Equal(command.SpaceId, note.SpaceId); Assert.Equal(command.Title, note.Title); Assert.Equal(command.Content, note.Content); Assert.Equal(command.Status, note.Status); if (status == NoteStatus.Draft) { Assert.Equal(0, note.Version); Assert.Equal(Visibility.Private, note.Visibility); } else { Assert.Equal(1, note.Version); Assert.Equal(Visibility.Public, note.Visibility); var noteHistories = await _noteQuery.GetHistoriesAsync(noteId); Assert.Single(noteHistories); } }
public async Task <IActionResult> GetHistoryAsync(Guid id) { return(Ok(await _noteQuery.GetHistoriesAsync(id))); }