public static WorkflowInputDataViewModel Create(IContextualResourceModel resourceModel, Guid sessionId, DebugMode debugMode) { VerifyArgument.IsNotNull(@"resourceModel", resourceModel); var debugInfoModel = ServiceDebugInfoModelFactory.CreateServiceDebugInfoModel(resourceModel, string.Empty, debugMode); var result = new WorkflowInputDataViewModel(debugInfoModel, sessionId); if (resourceModel?.Environment?.AuthorizationService != null) { result.CanDebug = resourceModel.UserPermissions.CanDebug(); } return(result); }
public void LoadInputs_Expected_Inputs_Loaded() { var mockResouce = GetMockResource(); var serviceDebugInfo = GetMockServiceDebugInfo(mockResouce); serviceDebugInfo.SetupGet(s => s.ServiceInputData).Returns(StringResourcesTest.DebugInputWindow_XMLData); var workflowInputDataviewModel = new WorkflowInputDataViewModel(serviceDebugInfo.Object, CreateDebugOutputViewModel().SessionID); workflowInputDataviewModel.LoadWorkflowInputs(); IList<IDataListItem> testDataListItems = GetInputTestDataDataNames(); for(int i = 1; i < workflowInputDataviewModel.WorkflowInputs.Count; i++) { Assert.AreEqual(testDataListItems[i].DisplayValue, workflowInputDataviewModel.WorkflowInputs[i].DisplayValue); Assert.AreEqual(testDataListItems[i].Value, workflowInputDataviewModel.WorkflowInputs[i].Value); } }
public static WorkflowInputDataViewModel Create(IContextualResourceModel resourceModel, Guid sessionId, DebugMode debugMode) { VerifyArgument.IsNotNull("resourceModel", resourceModel); var debugInfoModel = ServiceDebugInfoModelFactory.CreateServiceDebugInfoModel(resourceModel, string.Empty, debugMode); var result = new WorkflowInputDataViewModel(debugInfoModel, sessionId); if(resourceModel != null && resourceModel.Environment != null && resourceModel.Environment.AuthorizationService != null) { result.CanDebug = resourceModel.Environment.AuthorizationService.GetResourcePermissions(resourceModel.ID).CanDebug(); } return result; }
public void WorkflowInputDataViewModel_Constructor_DebugTO_Initialized() { //------------Setup for test-------------------------- var rm = new Mock<IContextualResourceModel>(); rm.Setup(r => r.ServerID).Returns(_serverID); rm.Setup(r => r.ResourceName).Returns(ResourceName); rm.Setup(r => r.WorkflowXaml).Returns(new StringBuilder(StringResourcesTest.DebugInputWindow_WorkflowXaml)); rm.Setup(r => r.ID).Returns(_resourceID); rm.Setup(r => r.DataList).Returns(StringResourcesTest.DebugInputWindow_DataList); var serviceDebugInfoModel = new ServiceDebugInfoModel { DebugModeSetting = DebugMode.DebugInteractive, RememberInputs = true, ResourceModel = rm.Object, ServiceInputData = "xxxxx" }; var debugVM = CreateDebugOutputViewModel(); //------------Execute Test--------------------------- var workflowInputDataViewModel = new WorkflowInputDataViewModel(serviceDebugInfoModel, debugVM.SessionID); //------------Assert Results------------------------- Assert.AreEqual(rm.Object.DataList, workflowInputDataViewModel.DebugTo.DataList); Assert.AreEqual(rm.Object.ResourceName, workflowInputDataViewModel.DebugTo.ServiceName); Assert.AreEqual(rm.Object.ResourceName, workflowInputDataViewModel.DebugTo.WorkflowID); // Travis 05.12 - Was rm.Object.WorkflowXaml.ToString(), since we no longer carry strings this was silly ;) Assert.AreEqual(string.Empty, workflowInputDataViewModel.DebugTo.WorkflowXaml); Assert.AreEqual(serviceDebugInfoModel.ServiceInputData, workflowInputDataViewModel.DebugTo.XmlData); Assert.AreEqual(rm.Object.ID, workflowInputDataViewModel.DebugTo.ResourceID); Assert.AreEqual(rm.Object.ServerID, workflowInputDataViewModel.DebugTo.ServerID); Assert.AreEqual(serviceDebugInfoModel.RememberInputs, workflowInputDataViewModel.DebugTo.RememberInputs); Assert.AreEqual(debugVM.SessionID, workflowInputDataViewModel.DebugTo.SessionID); Assert.IsTrue(workflowInputDataViewModel.DebugTo.IsDebugMode); }
public void SetWorkflowInputData_ExtraRows_Expected_Row_Available() { var mockResouce = GetMockResource(); var serviceDebugInfo = GetMockServiceDebugInfo(mockResouce); serviceDebugInfo.SetupGet(s => s.ServiceInputData).Returns(StringResourcesTest.DebugInputWindow_XMLData); var workflowInputDataviewModel = new WorkflowInputDataViewModel(serviceDebugInfo.Object, CreateDebugOutputViewModel().SessionID); workflowInputDataviewModel.LoadWorkflowInputs(); OptomizedObservableCollection<IDataListItem> inputValues = GetInputTestDataDataNames(); // Cannot perform Collection Assert due to use of mocks for datalist items to remove dependancies during test for(int i = 0; i < workflowInputDataviewModel.WorkflowInputs.Count; i++) { Assert.AreEqual(inputValues[i].DisplayValue, workflowInputDataviewModel.WorkflowInputs[i].DisplayValue); Assert.AreEqual(inputValues[i].Value, workflowInputDataviewModel.WorkflowInputs[i].Value); Assert.AreEqual(inputValues[i].IsRecordset, workflowInputDataviewModel.WorkflowInputs[i].IsRecordset); Assert.AreEqual(inputValues[i].RecordsetIndex, workflowInputDataviewModel.WorkflowInputs[i].RecordsetIndex); Assert.AreEqual(inputValues[i].Field, workflowInputDataviewModel.WorkflowInputs[i].Field); } }
public void SetWorkflowInputData_AddRow_WhenNotAllColumnsInput_ExpectNewRowWithOnlyInputColumns() { //------------Setup for test-------------------------- const string Shape = @"<DataList><rec Description="""" IsEditable=""True"" ColumnIODirection=""None"" ><a Description="""" IsEditable=""True"" ColumnIODirection=""Input"" /><b Description="""" IsEditable=""True"" ColumnIODirection=""None"" /></rec></DataList>"; var rm = new Mock<IContextualResourceModel>(); rm.Setup(r => r.ServerID).Returns(_serverID); rm.Setup(r => r.ResourceName).Returns(ResourceName); rm.Setup(r => r.WorkflowXaml).Returns(new StringBuilder(StringResourcesTest.DebugInputWindow_WorkflowXaml)); rm.Setup(r => r.ID).Returns(_resourceID); rm.Setup(r => r.DataList).Returns(Shape); var serviceDebugInfoModel = new ServiceDebugInfoModel { DebugModeSetting = DebugMode.DebugInteractive, RememberInputs = true, ResourceModel = rm.Object, ServiceInputData = "xxxxx" }; var debugVM = CreateDebugOutputViewModel(); var itemToAdd = new DataListItem { DisplayValue = "rec(1).a", Field = "a", Recordset = "rec", IsRecordset = true, RecordsetIndex = "1", RecordsetIndexType = enRecordsetIndexType.Numeric, Value = "1" }; //------------Execute Test--------------------------- var workflowInputDataViewModel = new WorkflowInputDataViewModel(serviceDebugInfoModel, debugVM.SessionID); workflowInputDataViewModel.LoadWorkflowInputs(); var inputs = workflowInputDataViewModel.WorkflowInputs; Assert.AreEqual(1, inputs.Count); inputs[0].Value = "1"; // trick it into thinking this happened from the UI ;) workflowInputDataViewModel.AddRow(itemToAdd); //------------Assert Results------------------------- inputs = workflowInputDataViewModel.WorkflowInputs; Assert.AreEqual(2, inputs.Count); }
public void Save_EmptyDataList_Expected_NoErrors() { var mockResouce = GetMockResource(); mockResouce.SetupGet(s => s.DataList).Returns(string.Empty); var serviceDebugInfo = GetMockServiceDebugInfo(mockResouce); var workflowInputDataviewModel = new WorkflowInputDataViewModel(serviceDebugInfo.Object, CreateDebugOutputViewModel().SessionID); workflowInputDataviewModel.LoadWorkflowInputs(); workflowInputDataviewModel.Save(); Assert.AreEqual("", workflowInputDataviewModel.DebugTo.Error); }
public void LoadInputs_NullDataList_Expected_Blank_Inputs() { var mockResouce = GetMockResource(); mockResouce.SetupGet(s => s.DataList).Returns(string.Empty); var serviceDebugInfo = GetMockServiceDebugInfo(mockResouce); var workflowInputDataviewModel = new WorkflowInputDataViewModel(serviceDebugInfo.Object, CreateDebugOutputViewModel().SessionID); workflowInputDataviewModel.LoadWorkflowInputs(); Assert.IsTrue(workflowInputDataviewModel.WorkflowInputs.Count == 0); }
public void LoadInputs_BlankXMLData_Expected_Blank_Inputs() { var mockResouce = GetMockResource(); var serviceDebugInfo = GetMockServiceDebugInfo(mockResouce); serviceDebugInfo.SetupGet(s => s.ServiceInputData).Returns("<DataList></DataList>"); var workflowInputDataviewModel = new WorkflowInputDataViewModel(serviceDebugInfo.Object, CreateDebugOutputViewModel().SessionID); workflowInputDataviewModel.LoadWorkflowInputs(); foreach(var input in workflowInputDataviewModel.WorkflowInputs) { Assert.AreEqual(string.Empty, input.Value); } }
public void CloseInputExpectFinishMessage() { var debugVM = CreateDebugOutputViewModel(); var mockResouce = GetMockResource(); var serviceDebugInfo = GetMockServiceDebugInfo(mockResouce); var workflowInputDataviewModel = new WorkflowInputDataViewModel(serviceDebugInfo.Object, debugVM.SessionID); workflowInputDataviewModel.DebugExecutionFinished += () => debugVM.DebugStatus = DebugStatus.Finished; workflowInputDataviewModel.ViewClosed(); Assert.AreEqual(DebugStatus.Finished, debugVM.DebugStatus); }
public void Cancel_NullDataList_Expected_NoErrors() { var mockResouce = GetMockResource(); var serviceDebugInfo = GetMockServiceDebugInfo(mockResouce); var workflowInputDataviewModel = new WorkflowInputDataViewModel(serviceDebugInfo.Object, CreateDebugOutputViewModel().SessionID); workflowInputDataviewModel.LoadWorkflowInputs(); workflowInputDataviewModel.Cancel(); Assert.AreEqual("", workflowInputDataviewModel.DebugTo.Error); }