public void FeedbackItemDataManager_DeleteFeedbackItem_CheckIfDBContainFourSettingAfterDeleting()
        {
            //arrange
            var feedbackItemRepository = new FeedbackItemRepository(_datacontext);
            FeedbackItemDataManager feedbackItemDataManager = new FeedbackItemDataManager(feedbackItemRepository);

            FeedbackItemData newFeedbackItem = new FeedbackItemData
               {
               FeedbackItemId = 5,
               Mandatory = false,
               SortNumber = 5,
               IsNumeric = false,
               FeedbackModelId = 2,
               NameTranslationKey = "NameTranslKey5",
               DescriptionTranslationKey = "DescrTranslation Key5"
               };

            //act
            feedbackItemDataManager.AddNewFeedbackItem(newFeedbackItem);
            var resultCountAfterAdding = feedbackItemDataManager.GetFeedbackItemsData().ToList().Count;
            feedbackItemDataManager.DeleteFeedbackItem(newFeedbackItem);
            var resultCountAfterDeleting = feedbackItemDataManager.GetFeedbackItemsData().ToList().Count;

            //assert
            Assert.AreEqual(6, resultCountAfterAdding);
            Assert.AreEqual(5, resultCountAfterDeleting);
        }
        public void FeedbackItemDataManager_AddNewFeedbackItem_CheckIfDBContainNewFeedbackItem()
        {
            //arrange
            var feedbackItemRepository = new FeedbackItemRepository(_datacontext);
            FeedbackItemDataManager feedbackItemDataManager = new FeedbackItemDataManager(feedbackItemRepository);

            FeedbackItemData newFeedbackItem = new FeedbackItemData
            {
                FeedbackItemId = 5,
                Mandatory = false,
                SortNumber = 5,
                IsNumeric = false,
                FeedbackModelId = 2,
                NameTranslationKey = "NameTranslKey5",
                DescriptionTranslationKey = "DescrTranslation Key5"
            };

            //act
            feedbackItemDataManager.AddNewFeedbackItem(newFeedbackItem);
            List<FeedbackItemData> result = feedbackItemDataManager.GetFeedbackItemsData();
            FeedbackItemData checkedFeedbackItem = result.Single(x => x.FeedbackItemId == newFeedbackItem.FeedbackItemId);

            //assert
            Assert.AreEqual(5, result.Count);
            Assert.AreEqual(newFeedbackItem.Mandatory, checkedFeedbackItem.Mandatory);
            Assert.AreEqual(newFeedbackItem.SortNumber, checkedFeedbackItem.SortNumber);
            Assert.AreEqual(newFeedbackItem.IsNumeric, checkedFeedbackItem.IsNumeric);
            Assert.AreEqual(newFeedbackItem.FeedbackModelId, checkedFeedbackItem.FeedbackModelId);
            Assert.AreEqual(newFeedbackItem.NameTranslationKey, checkedFeedbackItem.NameTranslationKey);
            Assert.AreEqual(newFeedbackItem.DescriptionTranslationKey, checkedFeedbackItem.DescriptionTranslationKey);
            Assert.AreEqual(newFeedbackItem.FeedbackItemId, checkedFeedbackItem.FeedbackItemId);
        }
        public void FeedbackItemDataManager_SetFeedbackItemsData_CheckIfDBContainUpdatedFeedbackItem()
        {
            //arrange
            var feedbackItemRepository = new FeedbackItemRepository(_datacontext);
            FeedbackItemDataManager feedbackItemDataManager = new FeedbackItemDataManager(feedbackItemRepository);
            FeedbackItemData newFeedbackItem = new FeedbackItemData
            {
                FeedbackItemId = 6,
                Mandatory = false,
                SortNumber = 5,
                IsNumeric = false,
                FeedbackModelId = 2,
                NameTranslationKey = "NameTranslKey5",
                DescriptionTranslationKey = "DescrTranslation Key5"
            };

            //act
            feedbackItemDataManager.AddNewFeedbackItem(newFeedbackItem);

            newFeedbackItem.Mandatory = true;
            newFeedbackItem.SortNumber = 100;
            newFeedbackItem.IsNumeric = true;
            newFeedbackItem.FeedbackModelId = 1;
            newFeedbackItem.NameTranslationKey = "NameTranslKey1";
            newFeedbackItem.DescriptionTranslationKey = "DescrTranslation Key1";

            feedbackItemDataManager.SetFeedbackItemsData(new List<FeedbackItemData>() { newFeedbackItem });
            var updatedList = feedbackItemDataManager.GetFeedbackItemsData().ToList();

            FeedbackItemData checkedFeedbackItem = updatedList.Single(x => x.FeedbackItemId == newFeedbackItem.FeedbackItemId);
            //assert

            Assert.AreEqual(6, updatedList.Count);
            Assert.AreEqual(newFeedbackItem.Mandatory, checkedFeedbackItem.Mandatory);
            Assert.AreEqual(newFeedbackItem.SortNumber, checkedFeedbackItem.SortNumber);
            Assert.AreEqual(newFeedbackItem.IsNumeric, checkedFeedbackItem.IsNumeric);
            Assert.AreEqual(newFeedbackItem.FeedbackModelId, checkedFeedbackItem.FeedbackModelId);
            Assert.AreEqual(newFeedbackItem.NameTranslationKey, checkedFeedbackItem.NameTranslationKey);
            Assert.AreEqual(newFeedbackItem.DescriptionTranslationKey, checkedFeedbackItem.DescriptionTranslationKey);
            Assert.AreEqual(newFeedbackItem.FeedbackItemId, checkedFeedbackItem.FeedbackItemId);
        }
Esempio n. 4
0
 /// <summary>
 /// Adds the new feedback item.
 /// </summary>
 /// <param name="feedbackItemForAdd">The feedback item for add.</param>
 public void AddNewFeedbackItem(FeedbackItemData feedbackItemForAdd)
 {
     try
     {
         var feedbackManager = new FeedbackItemDataManager();
         feedbackManager.AddNewFeedbackItem(feedbackItemForAdd);
     }
     catch (Exception ex)
     {
         //TODO ADD tracking
     }
 }