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_DeleteFeedbackItem_DeleteNonExistingItem()
        {
            //arrange
            var feedbackItemRepository = new FeedbackItemRepository(_datacontext);
            FeedbackItemDataManager feedbackItemDataManager = new FeedbackItemDataManager(feedbackItemRepository);

            FeedbackItemData newFeedbackItem = new FeedbackItemData
            {
                FeedbackItemId = 50,
                Mandatory = false,
                SortNumber = 50,
                IsNumeric = false,
                FeedbackModelId = 2,
                NameTranslationKey = "NameTranslKey50",
                DescriptionTranslationKey = "DescrTranslation Key50"
            };

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

            //assert
            Assert.AreEqual(resultCountBeforeDeleting, resultCountAfterDeleting);
        }
        public void FeedbackItemDataManager_SetFeedbackItemsData_UpdateNonExistingItem()
        {
            //arrange
            var feedbackItemRepository = new FeedbackItemRepository(_datacontext);
            FeedbackItemDataManager feedbackItemDataManager = new FeedbackItemDataManager(feedbackItemRepository);
            FeedbackItemData newFeedbackItem = new FeedbackItemData
            {
                FeedbackItemId = 50,
                Mandatory = false,
                SortNumber = 50,
                IsNumeric = false,
                FeedbackModelId = 2,
                NameTranslationKey = "NameTranslKey50",
                DescriptionTranslationKey = "DescrTranslation Key50"
            };

            //act
            feedbackItemDataManager.SetFeedbackItemsData(new List<FeedbackItemData>() { newFeedbackItem });
        }
        public void FeedbackItemDataManager_GetFeedbackItemsData_CheckIfDBContainFourSetting()
        {
            //arrange
            var feedbackItemRepository = new FeedbackItemRepository(_datacontext);
            FeedbackItemDataManager feedbackItemDataManager = new FeedbackItemDataManager(feedbackItemRepository);

            //act
            var result = feedbackItemDataManager.GetFeedbackItemsData().ToList().Count;

            //assert
            Assert.AreEqual(5, result);
        }
        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);
        }
Exemple #7
0
        /// <summary>
        /// Gets the user identifier or create new if not exist.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="userPassword">The user password.</param>
        /// <param name="userType">Type of the user.</param>
        /// <returns>
        /// Return user id
        /// </returns>
        public int GetUserIdOrCreateNewIfNotExist(string userName, string userPassword, string userType)
        {
            FeedbackItemDataManager feedbackItemManager = new FeedbackItemDataManager();
            int? existingUserId = feedbackItemManager.GetUserIdByName(userName);
            if (existingUserId.HasValue)
            {
                return existingUserId.Value;
            }

            return feedbackItemManager.CreateUser(userName, userPassword, userType);
        }
Exemple #8
0
        /// <summary>
        /// Gets the feedback controls list.
        /// </summary>
        /// <returns>The list of <see cref="FeedbackModelData"/>.</returns>
        public List<FeedbackModelData> GetFeedbackControlsList()
        {
            try
            {
                var feedbackManager = new FeedbackItemDataManager();

                return feedbackManager.GetFeedbackModels();
            }
            catch (Exception ex)
            {
                //TODO ADD tracking
                return new List<FeedbackModelData>();
            }
        }
Exemple #9
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
     }
 }
Exemple #10
0
 /// <summary>
 /// Deletes the feedback item.
 /// </summary>
 /// <param name="feedbackItemForDelete">The feedback item for delete.</param>
 public void DeleteFeedbackItem(FeedbackItemData feedbackItemForDelete)
 {
     try
     {
         var feedbackManager = new FeedbackItemDataManager();
         feedbackManager.DeleteFeedbackItem(feedbackItemForDelete);
     }
     catch (Exception ex)
     {
         //TODO ADD tracking
     }
 }
Exemple #11
0
 /// <summary>
 /// Sets the feedback items data.
 /// </summary>
 /// <param name="feedbackItemsDataList">The feedback items data list.</param>
 public void SetFeedbackItemsData(List<FeedbackItemData> feedbackItemsDataList)
 {
     try
     {
         var feedbackManager = new FeedbackItemDataManager();
         feedbackManager.SetFeedbackItemsData(feedbackItemsDataList);
     }
     catch (Exception ex)
     {
         //TODO ADD tracking
     }
 }