Beispiel #1
0
        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);
        }
Beispiel #2
0
 public static void InitializeDbForTests(NotesDbContext db)
 {
     db.Set <Note>().AddRange(GetNotesSeed());
     db.SaveChanges();
 }
Beispiel #3
0
 public static void ReinitializeDbForTests(NotesDbContext db)
 {
     db.Set <Note>().RemoveRange(db.Set <Note>());
     InitializeDbForTests(db);
 }