@@ -158,6 +158,111 @@ public async Task UpdatePostReadStatus_UpdatesAllPostsWithNotes()
158158 // This would require additional verification logic based on the actual implementation
159159 }
160160
161+ [ Fact ]
162+ public async Task GetNote_WithValidNoteId_ReturnsNote ( )
163+ {
164+ // Arrange
165+ var testPost = await CreateAndSaveTestPost ( ) ;
166+ var testNote = CreateTestNote ( ) ;
167+ testNote . PostId = testPost . RowKey ;
168+ await _client . PostAsJsonAsync ( "/api/notes/note" , testNote ) ;
169+
170+ // Act
171+ var response = await _client . GetAsync ( $ "/api/notes/note/{ testNote . RowKey } ") ;
172+
173+ // Assert
174+ response . StatusCode . Should ( ) . Be ( HttpStatusCode . OK ) ;
175+
176+ var retrievedNote = await response . Content . ReadFromJsonAsync < Note > ( ) ;
177+ retrievedNote . Should ( ) . NotBeNull ( ) ;
178+ retrievedNote ! . RowKey . Should ( ) . Be ( testNote . RowKey ) ;
179+ retrievedNote . Comment . Should ( ) . Be ( testNote . Comment ) ;
180+ }
181+
182+ [ Fact ]
183+ public async Task GetNote_WithInvalidNoteId_ReturnsNotFound ( )
184+ {
185+ // Arrange
186+ var nonExistentNoteId = "non-existent-note-id" ;
187+
188+ // Act
189+ var response = await _client . GetAsync ( $ "/api/notes/note/{ nonExistentNoteId } ") ;
190+
191+ // Assert
192+ response . StatusCode . Should ( ) . Be ( HttpStatusCode . NotFound ) ;
193+ }
194+
195+ [ Fact ]
196+ public async Task UpdateNote_WithValidNote_ReturnsOk ( )
197+ {
198+ // Arrange
199+ var testPost = await CreateAndSaveTestPost ( ) ;
200+ var testNote = CreateTestNote ( ) ;
201+ testNote . PostId = testPost . RowKey ;
202+ await _client . PostAsJsonAsync ( "/api/notes/note" , testNote ) ;
203+
204+ // Update the note
205+ testNote . Comment = "Updated comment" ;
206+ testNote . Tags = "updated, tags" ;
207+
208+ // Act
209+ var response = await _client . PutAsJsonAsync ( "/api/notes/note" , testNote ) ;
210+
211+ // Assert
212+ response . StatusCode . Should ( ) . Be ( HttpStatusCode . OK ) ;
213+
214+ var updatedNote = await response . Content . ReadFromJsonAsync < Note > ( ) ;
215+ updatedNote . Should ( ) . NotBeNull ( ) ;
216+ updatedNote ! . Comment . Should ( ) . Be ( "Updated comment" ) ;
217+ updatedNote . Tags . Should ( ) . Be ( "updated, tags" ) ;
218+ }
219+
220+ [ Fact ]
221+ public async Task UpdateNote_WithInvalidNote_ReturnsBadRequest ( )
222+ {
223+ // Arrange
224+ var invalidNote = new Note ( ) ; // Missing required comment
225+
226+ // Act
227+ var response = await _client . PutAsJsonAsync ( "/api/notes/note" , invalidNote ) ;
228+
229+ // Assert
230+ response . StatusCode . Should ( ) . Be ( HttpStatusCode . BadRequest ) ;
231+ }
232+
233+ [ Fact ]
234+ public async Task DeleteNote_WithValidNoteId_ReturnsOk ( )
235+ {
236+ // Arrange
237+ var testPost = await CreateAndSaveTestPost ( ) ;
238+ var testNote = CreateTestNote ( ) ;
239+ testNote . PostId = testPost . RowKey ;
240+ await _client . PostAsJsonAsync ( "/api/notes/note" , testNote ) ;
241+
242+ // Act
243+ var response = await _client . DeleteAsync ( $ "/api/notes/note/{ testNote . RowKey } ") ;
244+
245+ // Assert
246+ response . StatusCode . Should ( ) . Be ( HttpStatusCode . OK ) ;
247+
248+ // Verify the note is deleted
249+ var getResponse = await _client . GetAsync ( $ "/api/notes/note/{ testNote . RowKey } ") ;
250+ getResponse . StatusCode . Should ( ) . Be ( HttpStatusCode . NotFound ) ;
251+ }
252+
253+ [ Fact ]
254+ public async Task DeleteNote_WithInvalidNoteId_ReturnsNotFound ( )
255+ {
256+ // Arrange
257+ var nonExistentNoteId = "non-existent-note-id" ;
258+
259+ // Act
260+ var response = await _client . DeleteAsync ( $ "/api/notes/note/{ nonExistentNoteId } ") ;
261+
262+ // Assert
263+ response . StatusCode . Should ( ) . Be ( HttpStatusCode . NotFound ) ;
264+ }
265+
161266 // Helper methods
162267 private async Task SeedTestNotes ( )
163268 {
0 commit comments