/// <summary>
        /// Displays the list of inventory 
        /// </summary>
        /// <returns></returns>
        public ActionResult InventoryDetail()
        {
            StringBuilder objStringBuilderError = new StringBuilder();
            try
            {
                if (Session["UserName"] != null)
                {
                    InventorySearchModel inventorySearchModel = new InventorySearchModel();
                    IEnumerable<InventoryModel> lstInventoryDetails;
                    List<DeviceModel> devices;
                    using (JetstreamClient objMainServiceClient = new JetstreamClient())
                    {
                        lstInventoryDetails = objMainServiceClient.GetInventoryList(inventorySearchModel.LogicalDeviceId, inventorySearchModel.SearchString);
                        devices = objMainServiceClient.GetDeviceList();
                    }

                    List<SelectListItem> deviceList = new SelectList(devices.OrderBy(x => x.LogicalDeviceId), "LogicalDeviceId", "LogicalDeviceId").ToList();
                    deviceList.Insert(0, new SelectListItem { Text = JetstreamResource.All, Value = string.Empty });
                    ViewBag.DeviceList = deviceList;

                    SortingPagingInfo info = new SortingPagingInfo
                    {
                        SortField = Enums.InventorySortField.Material.ToString(),
                        SortDirection = Constants.Ascending,
                    };
                    lstInventoryDetails = lstInventoryDetails.OrderBy(x => x.Material).Take(Constants.PagingPageSize);
                    ViewBag.SortingPagingInfo = info;

                    if (lstInventoryDetails.Any())
                        inventorySearchModel.InventoryModels = lstInventoryDetails.ToList();

                    return View("InventoryDetail", inventorySearchModel);
                }
                else
                {
                    return RedirectToAction("UserLogin", "Login");
                }
            }
            catch (FaultException<ServiceData> fex)
            {
                objStringBuilderError.AppendLine("In method : InventoryDetail() :: InventoryController");
                objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", fex.Detail.ErrorMessage, Environment.NewLine);
                objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, fex.Detail.ErrorDetails);

                SaveLogger.SaveLoggerError(objStringBuilderError.ToString());
                return View("Error");
            }
            catch (Exception ex)
            {
                objStringBuilderError.AppendLine("In method : InventoryDetail() :: InventoryController");
                objStringBuilderError.AppendFormat("ErrorMessage::{0} {1}", ex.Message, Environment.NewLine);
                objStringBuilderError.AppendFormat("ErrorDetails::{0} {1}", Environment.NewLine, ex.ToString());

                SaveLogger.SaveLoggerError(objStringBuilderError.ToString());
                return View("Error");
            }
        }
        public void InventorySearch_OnPost_WithSessionNotNull_ExpectOk()
        {
            //Arrange
            String expectedView = "InventoryDetail";
            _controllerContext.Setup(cc => cc.HttpContext.Session["UserName"]).Returns(string.Format("{0} {1}", "FName", "LName"));
            _inventoryController.ControllerContext = _controllerContext.Object;
            InventorySearchModel inventorySearchModel = new InventorySearchModel
            {
                LogicalDeviceId = "ChetuTestDeviceId",
                SearchString = "test"
            };
            SortingPagingInfo info = new SortingPagingInfo
            {
                SortField = Enums.InventorySortField.Material.ToString(),
                SortDirection = Constants.Ascending,
            };

            //Act
            var actionResult = _inventoryController.InventoryDetail() as ViewResult;

            //Assert
            Assert.IsNotNull(actionResult, "InventorySearch action result should not be null");
            Assert.AreEqual(actionResult.ViewName, expectedView, "View name should be InventoryDetail");
        }
        public void InventorySearch_OnPost_WithSessionIsNull_ExpectUserLogin()
        {
            //Arrange
            String expectedController = "Login";
            String expectedAction = "UserLogin";
            _controllerContext.Setup(cc => cc.HttpContext.Session["UserName"]).Returns(null);
            _inventoryController.ControllerContext = _controllerContext.Object;
            InventorySearchModel inventorySearchModel = new InventorySearchModel
            {
                LogicalDeviceId = "ChetuTestDeviceId",
                SearchString = "test"
            };
            SortingPagingInfo info = new SortingPagingInfo
            {
                SortField = Enums.InventorySortField.Material.ToString(),
                SortDirection = Constants.Ascending,
            };

            //Act
            var redirectToRouteResult = _inventoryController.InventoryDetail() as RedirectToRouteResult;

            // Assert
            Assert.IsNotNull(redirectToRouteResult, "Not a redirect result");
            Assert.IsFalse(redirectToRouteResult.Permanent); // Or IsTrue if you use RedirectToActionPermanent
            Assert.AreEqual(expectedAction, redirectToRouteResult.RouteValues["Action"]);
            Assert.AreEqual(expectedController, redirectToRouteResult.RouteValues["Controller"]);
        }