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_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); }
/// <summary> /// Deletes the feedback item. /// </summary> /// <param name="feedbackItem">The feedback item.</param> public void DeleteFeedbackItem(FeedbackItemData feedbackItem) { var feedbackItemForSave =new FeedbackItem { FeedbackItemId = feedbackItem.FeedbackItemId, NameTranslationKey = feedbackItem.NameTranslationKey, SortNumber = feedbackItem.SortNumber, DescriptionTranslationKey = feedbackItem.DescriptionTranslationKey, IsNumeric = feedbackItem.IsNumeric, Mandatory = feedbackItem.Mandatory, FeedbackModelId = feedbackItem.FeedbackModelId }; _feedbackItemRepository.DeleteFeedbackItemData(feedbackItemForSave); }
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_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); }
/// <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 } }
/// <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 } }