Пример #1
0
        public void ShouldReturnItemNotificationByItemId()
        {
            // arrange
            Item             item         = PrepareItem("name", "descritpion", TODAY, false);
            ItemNotification notification = PrepareItemNotification(item, TODAY, false);

            dbContext.Items.Add(item);
            dbContext.ItemNotifications.Add(notification);
            dbContext.SaveChanges();

            // act
            ItemNotification returnedItemNotification = itemNotificationRepository.FindByItemId(item.Id);

            // assert
            Assert.AreEqual(notification, returnedItemNotification);
        }
        public void ShouldDeleteItemAndItsNotification()
        {
            // arrange
            Item             item         = PrepareItem("name", "descritpion", TODAY, false);
            ItemNotification notification = PrepareItemNotification(item, TODAY, false);

            dbContext.Items.Add(item);
            dbContext.ItemNotifications.Add(notification);
            dbContext.SaveChanges();

            // act
            itemRepository.Delete(item);

            // assert
            List <Item>      items = itemRepository.FindByDate(TODAY);
            ItemNotification returnedNotification = itemNotificationRepository.FindByItemId(item.Id);

            Assert.AreEqual(0, items.Count);
            Assert.IsNull(returnedNotification);
        }
 public ItemNotification GetItemNotificationByItemId(long itemId)
 {
     return(itemNotificationRepository.FindByItemId(itemId));
 }