예제 #1
0
    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());
    }
예제 #2
0
    private async Task ThenTheNoteShouldBeRestored()
    {
        var note = await _noteQuery.GetNoteAsync(_noteId);

        Assert.Equal(4, note.Version);
        Assert.Equal(_editNoteCommandForRestore.Title, note.Title);
        Assert.Equal(_editNoteCommandForRestore.Content, note.Content);
    }
예제 #3
0
    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);
        }
    }
예제 #4
0
 public async Task <IActionResult> GetAsync(Guid id)
 {
     return(Ok(await _noteQuery.GetNoteAsync(id)));
 }