Esempio n. 1
0
 public void ClearDb()
 {
     using (var context = new ContactBookAPIContext(options))
     {
         context.ContactItem.RemoveRange(context.ContactItem);
         context.SaveChanges();
     };
 }
Esempio n. 2
0
        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;
            }
        }
Esempio n. 3
0
        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();
            }
        }
Esempio n. 4
0
        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));
            }
        }
Esempio n. 5
0
        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;
 }