public void ClearDb() { using (var context = new ContactBookAPIContext(options)) { context.ContactItem.RemoveRange(context.ContactItem); context.SaveChanges(); }; }
public async Task TestPostContactItem() { using (var context = new ContactBookAPIContext(options)) { // Given ContactItem memeitem1 = new ContactItem(); // When ContactItemsController ContactController = new ContactItemsController(context, configuration); IActionResult result = await ContactController.PostContactItem(memeitem1) as IActionResult; } }
public async Task TestPutContactItemUpdate() { using (var context = new ContactBookAPIContext(options)) { // Given string title = "putMeme"; ContactItem memeItem1 = context.ContactItem.Where(x => x.Title == memeTitles[0]).Single(); memeItem1.Title = title; // When ContactItemsController ContactController = new ContactItemsController(context, configuration); IActionResult result = await ContactController.PutContactItem(memeItem1.Id, memeItem1) as IActionResult; // Then memeItem1 = context.ContactItem.Where(x => x.Title == title).Single(); } }
public async Task TestPutMemeContactNoContentStatusCode() { using (var context = new ContactBookAPIContext(options)) { // Given string title = "putMeme"; ContactItem memeItem1 = context.ContactItem.Where(x => x.Title == memeTitles[0]).Single(); memeItem1.Title = title; // When ContactItemsController ContactController = new ContactItemsController(context, configuration); IActionResult result = await ContactController.PutContactItem(memeItem1.Id, memeItem1) as IActionResult; // Then Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(NoContentResult)); } }
public void SetupDb() { using (var context = new ContactBookAPIContext(options)) { ContactItem contactitem1 = new ContactItem() { Title = memeTitles[0] }; ContactItem contactitem2 = new ContactItem() { Title = memeTitles[1] }; context.ContactItem.Add(contactitem1); context.ContactItem.Add(contactitem2); context.SaveChanges(); } }
public ContactItemsController(ContactBookAPIContext context, IConfiguration configuration) { _context = context; _configuration = configuration; }