void TryShowDataInOutputWindow(WorkflowInputDataViewModel vm) { if (_currentTab == InputTab.Grid) { try { vm.SetXmlData(); ShowDataInOutputWindow(vm.XmlData); } catch { vm.ShowInvalidDataPopupMessage(); } } if (_currentTab == InputTab.Json) { try { vm.XmlData = GetXmlDataFromJson(); vm.SetWorkflowInputData(); vm.SetXmlData(); ShowDataInOutputWindow(vm.XmlData); } catch { vm.ShowInvalidDataPopupMessage(); } } }
void ShowDataInJsonOutputWindow(WorkflowInputDataViewModel vm, string input) { if (!string.IsNullOrEmpty(input)) { var xml = new XmlDocument(); try { xml.LoadXml(input); } catch (Exception ex) { vm.ShowInvalidDataPopupMessage(); } if (xml.FirstChild != null) { var json = JsonConvert.SerializeXmlNode(xml.FirstChild, Newtonsoft.Json.Formatting.Indented, true); _jsonEditor.Text = json; } else { _jsonEditor.Text = vm.JsonData; } JsonOutput.Content = _jsonEditor; } }
WorkflowInputDataViewModel GetWorkflowInputDataViewModel(IContextualResourceModel resourceModel, bool isDebug) { var mode = isDebug ? DebugMode.DebugInteractive : DebugMode.Run; var inputDataViewModel = WorkflowInputDataViewModel.Create(resourceModel, DebugOutputViewModel.SessionID, mode); inputDataViewModel.Parent = this; return(inputDataViewModel); }
public void WorkflowInputDataViewModel_Create_NullResourceModel_ThrowException() { //------------Setup for test-------------------------- //------------Execute Test--------------------------- WorkflowInputDataViewModel.Create(null); //------------Assert Results------------------------- }
void MoveToPreviousRow(WorkflowInputDataViewModel vm) { var itemToSelect = vm?.GetPreviousRow(DataListInputs.ActiveItem as IDataListItem); if (itemToSelect != null) { DataListInputs.ActiveItem = itemToSelect; FocusOnAddition(); } }
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); }
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 WorkflowInputDataViewModel_Create_WithResourceModel_IsValid() { //------------Setup for test-------------------------- var mockResouce = GetMockResource(); //------------Execute Test--------------------------- var viewModel = WorkflowInputDataViewModel.Create(mockResouce.Object); //------------Assert Results------------------------- Assert.IsNotNull(viewModel); Assert.IsNotNull(viewModel.DebugTo); }
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 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_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 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 void SetWorkflowInputData_RemoveRow_WhenNotAllColumnsInput_ExpectRowRemoved() { //------------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 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 ;) int indexToSelect; workflowInputDataViewModel.AddBlankRow(inputs[0], out indexToSelect); //------------Execute Test--------------------------- workflowInputDataViewModel.RemoveRow(inputs[0], out indexToSelect); //------------Assert Results------------------------- inputs = workflowInputDataViewModel.WorkflowInputs; Assert.AreEqual(3, inputs.Count); var count = workflowInputDataViewModel.WorkflowInputCount; Assert.AreEqual(3, count); }
public void SetWorkflowInputData_WithObject_ShouldAddToPayload() { //------------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><Person Description="""" IsEditable=""True"" ColumnIODirection=""Input"" IsJson=""True""><Name></Name><Age></Age></Person></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 mockDataListViewModel = new Mock <IDataListViewModel>(); var personObject = new ComplexObjectItemModel("Person", null, enDev2ColumnArgumentDirection.Input); personObject.Children.Add(new ComplexObjectItemModel("Age", personObject, enDev2ColumnArgumentDirection.Input)); personObject.Children.Add(new ComplexObjectItemModel("Name", personObject, enDev2ColumnArgumentDirection.Input)); var complexObjectItemModels = new ObservableCollection <IComplexObjectItemModel> { personObject }; mockDataListViewModel.Setup(model => model.ComplexObjectCollection).Returns(complexObjectItemModels); DataListSingleton.SetDataList(mockDataListViewModel.Object); var serviceDebugInfoModel = new ServiceDebugInfoModel { DebugModeSetting = DebugMode.DebugInteractive, RememberInputs = true, ResourceModel = rm.Object, ServiceInputData = "xxxxx" }; var debugVM = CreateDebugOutputViewModel(); var workflowInputDataViewModel = new WorkflowInputDataViewModel(serviceDebugInfoModel, debugVM.SessionID); workflowInputDataViewModel.LoadWorkflowInputs(); var inputs = workflowInputDataViewModel.WorkflowInputs; Assert.AreEqual(2, inputs.Count); inputs[0].Value = "bob"; //------------Execute Test--------------------------- workflowInputDataViewModel.SetXmlData(); //------------Assert Results------------------------- Assert.AreEqual("<DataList><recjson:Array=\"true\"xmlns:json=\"http://james.newtonking.com/projects/json\"><a>bob</a></rec><Person><Age></Age><Name></Name></Person></DataList>", workflowInputDataViewModel.XmlData.Replace(Environment.NewLine, "").Replace(" ", "")); }
void TryChangeTab(WorkflowInputDataViewModel vm) { try { var xmlData = _editor.Text; if (_currentTab == InputTab.Json) { xmlData = GetXmlDataFromJson(); } vm.XmlData = xmlData; vm.SetWorkflowInputData(); _currentTab = InputTab.Grid; } catch (Exception ex) { vm.IsInError = true; } }
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); }
private void SetCurrentTabToJson(WorkflowInputDataViewModel vm) { string input = string.Empty; if (_currentTab == InputTab.Grid) { vm.SetXmlData(); if (vm.XmlData != null) { input = vm.XmlData; } } if (_currentTab == InputTab.Xml && !string.IsNullOrEmpty(_editor.Text)) { input = _editor.Text; } ShowDataInJsonOutputWindow(vm, input); _currentTab = InputTab.Json; }
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); } }
private void SetCurrentTabToJson(WorkflowInputDataViewModel vm) { var xml = new XmlDocument(); if (_currentTab == InputTab.Grid) { vm.SetXmlData(); if (vm.XmlData != null) { xml.LoadXml(vm.XmlData); } } if (_currentTab == InputTab.Xml && !string.IsNullOrEmpty(_editor.Text)) { try { xml.LoadXml(_editor.Text); } catch (Exception ex) { vm.ShowInvalidDataPopupMessage(); } } if (!string.IsNullOrEmpty(vm.JsonData)) { _jsonEditor.Text = vm.JsonData; } else { if (xml.FirstChild != null) { var json = JsonConvert.SerializeXmlNode(xml.FirstChild, Newtonsoft.Json.Formatting.Indented, true); _jsonEditor.Text = json; } } JsonOutput.Content = _jsonEditor; _currentTab = InputTab.Json; }
void TrySetWorkflowInputData(TabItem tabItem, WorkflowInputDataViewModel vm) { if (tabItem.Header.ToString() == "XML") { try { vm.XmlData = _editor.Text; vm.SetWorkflowInputData(); } catch (Exception ex) { vm.IsInError = true; } } else { if (tabItem.Header.ToString() == "JSON") { vm.XmlData = GetXmlDataFromJson(); vm.SetWorkflowInputData(); } } }
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); }