コード例 #1
0
 private void SetupWindowData()
 {
     SelectedItemNotification = itemNotificationController.GetItemNotificationByItemId(SelectedItem.Id);
     ItemName.Text            = SelectedItem.Name;
     ItemDescription.Text     = SelectedItem.Description;
     ItemDate.Text            = String.Format("{0:yyyy-MM-dd HH:mm}", SelectedItem.Date);
 }
コード例 #2
0
    public void AddNotification(string content)
    {
        SoundManager.instance.SFX_Notification();
        ItemNotification itemNotification = Instantiate(itemNotificationPrefab, gameObject.transform);

        itemNotification.ShowNotification(content);
    }
コード例 #3
0
        public void ShouldThrowDbUpdateExceptionWhenSameNotificationWillBeSavedTwoTimes()
        {
            // arrange
            Item item = new Item
            {
                Name        = "name",
                Description = "descritpion",
                Date        = DateTime.Now
            };

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

            ItemNotification invalidNotification = new ItemNotification
            {
                Item             = item,
                ItemId           = item.Id,
                Notified         = false,
                NotifiactionDate = DateTime.Now
            };

            // act
            itemNotificationRepository.Save(invalidNotification);
            itemNotificationRepository.Save(invalidNotification);
        }
コード例 #4
0
 public CustomDisplayPart(ItemNotification itemNotification)
 {
     _itemNotification = itemNotification;
     DataContext       = itemNotification; // this allows to bind ui with data in notification
     InitializeComponent();
     WtTextBlock.Text = itemNotification.PostLoad.Type == OrderType.Buy ? "WTB" : "WTS";
     Image.MouseUp   += ClickImage;
 }
コード例 #5
0
        public void ShouldCallDeleteOnItemNotificationRepository()
        {
            // arrange
            ItemNotification itemNotification = new ItemNotification();

            // act
            itemNotificationController.DeleteItemNotification(itemNotification);

            // assert
            mockItemNotificationRepository.Verify(x => x.Delete(itemNotification), Times.Once);
        }
コード例 #6
0
        public void ShouldReturnItemNotificationByItemId()
        {
            // arrange
            long             itemId = 1;
            ItemNotification expectedItemNotification = new ItemNotification();

            mockItemNotificationRepository.Setup(c => c.FindByItemId(itemId)).Returns(expectedItemNotification);

            // act
            ItemNotification returnedItemNotification = itemNotificationController.GetItemNotificationByItemId(itemId);

            // assert
            Assert.AreEqual(expectedItemNotification, returnedItemNotification);
        }
コード例 #7
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);
        }
コード例 #8
0
    /// <summary>
    /// Move up existing notifications.
    /// if required.
    /// </summary>
    private void MoveNotsUp()
    {
        foreach (GameObject prefab in _notPool.pool)
        {
            if (prefab.activeSelf == true)
            {
                ItemNotification itemNot = prefab.gameObject.GetComponent <ItemNotification>();

                if (itemNot.displayed)
                {
                    // move up displayed notifications.
                    itemNot.MoveUp();
                }
            }
        }
    }
コード例 #9
0
        public void ShouldThrowEntityValidationExceptionWhenItemIsNull()
        {
            // arrange
            Item item = new Item();

            dbContext.Items.Add(item);

            ItemNotification invalidNotification = new ItemNotification
            {
                ItemId           = item.Id,
                Notified         = false,
                NotifiactionDate = DateTime.Now
            };

            // act
            itemNotificationRepository.Save(invalidNotification);
        }
コード例 #10
0
        public void ShoulDeleteItemNotification()
        {
            // 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
            itemNotificationRepository.Delete(notification);

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

            Assert.IsNull(returnedItemNotification);
        }
コード例 #11
0
        public void ShoulUpdateItemNotification()
        {
            // 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
            notification.Notified = true;
            itemNotificationRepository.Update(notification);

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

            Assert.AreEqual(true, returnedItemNotification.Notified);
        }
コード例 #12
0
 void NotificationSettingsWindowActivated(object sender, EventArgs e)
 {
     SelectedItemNotification = null;
     try
     {
         SetupWindowData();
         if (SelectedItemNotification != null)
         {
             SetUpNotificationControls(SelectedItemNotification.NotifiactionDate, true);
         }
         else
         {
             SetUpNotificationControls(null, false);
         }
     }
     catch (Exception ex)
     {
         excpetionHandler.HandleException(ex);
     }
 }
コード例 #13
0
        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);
        }
コード例 #14
0
        public void ShoulReturnNotNotifiedItemsNotificaitonsByDateTime()
        {
            // arrange
            Item             firstItem          = PrepareItem("name1", "descritpion1", TODAY, false);
            ItemNotification firstNotification  = PrepareItemNotification(firstItem, TODAY, false);
            Item             secondItem         = PrepareItem("name2", "descritpion2", TODAY, false);
            ItemNotification secondNotification = PrepareItemNotification(secondItem, TODAY, true);

            dbContext.Items.Add(firstItem);
            dbContext.Items.Add(secondItem);
            dbContext.ItemNotifications.Add(firstNotification);
            dbContext.ItemNotifications.Add(secondNotification);
            dbContext.SaveChanges();

            // act
            List <ItemNotification> returnedNotifications = itemNotificationRepository.FindNotNotifiedByNotificationDate(TODAY);

            // assert
            Assert.AreEqual(1, returnedNotifications.Count);
            CollectionAssert.Contains(returnedNotifications, firstNotification);
        }
コード例 #15
0
 public void DeleteItemNotification(ItemNotification itemNotification)
 {
     itemNotificationRepository.Delete(itemNotification);
 }
コード例 #16
0
 private void UpdateNotificationStatus(ItemNotification notification)
 {
     notification.Notified = true;
     itemNotificationRepository.Update(notification);
 }
コード例 #17
0
 public void SaveItemNotification(ItemNotification itemNotification)
 {
     itemNotificationRepository.Save(itemNotification);
 }
コード例 #18
0
 public void Save(ItemNotification notification)
 {
     dbContext.Entry(notification).State = EntityState.Added;
     dbContext.SaveChanges();
 }
コード例 #19
0
 public void Update(ItemNotification notification)
 {
     dbContext.Entry(notification).State = EntityState.Modified;
     dbContext.SaveChanges();
 }
コード例 #20
0
 public override void Clear()
 {
     itemInfoList.Clear();
     notification = null;
 }
コード例 #21
0
 public void Delete(ItemNotification notification)
 {
     dbContext.ItemNotifications.Remove(notification);
     dbContext.SaveChanges();
 }