public async Task Add_AddsToDbAndReturnsOk_ForProperNote() { // Arrange var client = _factory.CreateClient(); var newNote = new NoteForAddingDto() { Title = "title X", Content = "content X" }; var newNoteJson = JsonSerializer.Serialize(newNote); var httpContent = new StringContent(newNoteJson, Encoding.UTF8); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); // Act var response = await client.PostAsync(Consts.postUrl, httpContent); // Assert Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.True(_dbContext.Set <Note>().Find(Consts.newNoteId) != null); }
public static void InitializeDbForTests(NotesDbContext db) { db.Set <Note>().AddRange(GetNotesSeed()); db.SaveChanges(); }
public static void ReinitializeDbForTests(NotesDbContext db) { db.Set <Note>().RemoveRange(db.Set <Note>()); InitializeDbForTests(db); }