public void EditProductGroup() { string submit = "Update"; ProductGroup productgroup = new ProductGroup(); { productgroup.Product_Group_Id = 3; productgroup.Product_Group_Name = "Camera"; productgroup.Level = 22; } mockProductGroupRepository.Setup(m => m.EditExistingProductGroup(productgroup)).Returns(true); var productgrouplist = new ProductGroupViewModels(); { productgroup.Product_Group_Id = 3; productgroup.Product_Group_Name = "Camera"; productgroup.Level = 22; } productgrouplist.ProductGroup = productgroup; // Now invoke the Index action. var actionResult = productgroupcontroller.Index(submit, productgrouplist); // Validate the expected result. ViewResult expectedResult = new ViewResult(); Assert.IsNotNull(actionResult); //(branchList, (actionResult.Model as BranchViewModels).BranchList); }
private void XMLGenerate_SAPUpdate(ProductGroupViewModels model) { try { ApplicationUser currentUser = ApplicationUserManager.GetApplicationUser(User.Identity.Name, HttpContext.GetOwinContext()); //unique id generation Guid GuidRandomNo = Guid.NewGuid(); string UniqueID = GuidRandomNo.ToString(); //fill view model Viewmodel_ModifyProductGroup xmlEditProductGroup = new Viewmodel_ModifyProductGroup(); xmlEditProductGroup.UniqueID = UniqueID.ToString(); xmlEditProductGroup.old_Productgroup_Name = Temp_productgroup.ToString().Trim(); xmlEditProductGroup.New_Productgroup_Name = model.ProductGroup.Product_Group_Name; xmlEditProductGroup.LastModifyUser = currentUser.Id.ToString(); xmlEditProductGroup.LastModifyBranch = currentUser.Modified_Branch_Id.ToString(); xmlEditProductGroup.LastModifyDateTime = DateTime.Now.ToString(); //generate xml productgroupRepository.GenerateXML(xmlEditProductGroup, UniqueID); } catch (Exception ex) { ExceptionHandler.LogException(ex); ViewBag.AppErrorMessage = ex.Message; } }
public void saveProductGroup() { string submit = "Save"; /* * First identify the repository methods which are invoked form Index action. Then Setup the mock * for all the identified methods. * * Then invoke the Controller's Index action with necessary input parameters and ensure that you have * invoked the Index action for all the different cases (code blocks) available in that, which should * cover all the blocks/statements in the Index action. * */ #region Arrange // Prepare the return data for GetAllQuotation() method. ProductGroup productgroup = new ProductGroup(); { productgroup.Product_Group_Id = 3; productgroup.Product_Group_Name = "Camera"; productgroup.Level = 22; } mockProductGroupRepository.Setup(m => m.AddNewProductGroup(productgroup)).Returns(true); var productgrouplist = new ProductGroupViewModels(); { productgroup.Product_Group_Id = 3; productgroup.Product_Group_Name = "Camera"; productgroup.Level = 22; } productgrouplist.ProductGroup = productgroup; #endregion // Now invoke the Index action. //var actionResult = manufacturercontroller.Index(submit, manufacturerlist) as ViewResult; var actionResult = productgroupcontroller.Index(submit, productgrouplist); // Validate the expected result. ViewResult expectedResult = new ViewResult(); Assert.IsNotNull(actionResult); //Assert.AreEqual(manufacturerlist, (actionResult.Model as ManufacturerViewModels).ManufacturerList); }
// GET: ProductGroup public ActionResult Index(string searchColumn, string searchQuery) { try { LogHandler.WriteLog("Purchase Index page requested by #UserId"); var qList = productgroupRepository.GetAllProductGroup(); //GetUserId(); ProductGroupViewModels model = new ProductGroupViewModels(); model.ProductGroupList = qList; return(View(model)); } catch (Exception ex) { ExceptionHandler.LogException(ex); ViewBag.AppErrorMessage = ex.Message; return(View("Error")); } }