private void GetMockedObject(HomeController controller) { AccountDTO[] accountDTO = new AccountDTO[] { new AccountDTO { AccountID = "TestAccountID", AccountName = "Test Account Name" } }; ReportDTO[] reportDTO = new ReportDTO[] { new ReportDTO { ReportID = 1, ReportName = "Test Report Name" } }; NodeDTO[] nodeDTO = new NodeDTO[] { new NodeDTO { NodeID = "TestNodeID", DisplayValue = "Test Node Name" } }; Mock <ICertonaService> applicationMock = new Mock <ICertonaService>(); controller.ForesightService = applicationMock.Object; GetAccountsByUserResponse accountsByUserResponse = new GetAccountsByUserResponse { Success = true, Accounts = accountDTO }; GetPanelBarWidthResponse panelBarWidthResponse = new GetPanelBarWidthResponse { Width = 100 }; GetReportsListResponse reportsListResponse = new GetReportsListResponse { Reports = reportDTO }; GetAccountExplorerTreeResponse accountExplorerTreeResponse = new GetAccountExplorerTreeResponse { Nodes = nodeDTO }; applicationMock.Setup(p => p.GetAccountsByUser(It.IsAny <GetAccountsByUserRequest>())).Returns(accountsByUserResponse); applicationMock.Setup(p => p.GetPanelBarWidth(It.IsAny <GetPanelBarWidthRequest>())).Returns(panelBarWidthResponse); applicationMock.Setup(p => p.GetReportsList(It.IsAny <GetReportsListRequest>())).Returns(reportsListResponse); applicationMock.Setup(p => p.GetAccountExplorerTree(It.IsAny <GetAccountExplorerTreeRequest>())).Returns(accountExplorerTreeResponse); }
public PartialViewResult GetAccountTreeview() { try { UserDTO user = FormsAuthenticationWrapper.User; var accountExplorerTreeRequest = new GetAccountExplorerTreeRequest { User = user }; GetAccountExplorerTreeResponse accountExplorerTreeResponse = ForesightService.GetAccountExplorerTree(accountExplorerTreeRequest); return(PartialView("_AccountTreeView", accountExplorerTreeResponse.Nodes.ToList())); } catch (Exception ex) { LoggingHelper.Logger.WriteException(ex); return(PartialView("_AccountTreeView", new List <NodeDTO>())); } }