public void UpdateAllOccurrences_Same_Object_Is_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var multiAssign = new DsfMultiAssignActivity() { UniqueID = uniqueId, FieldsCollection = new List <ActivityDTO>() { new ActivityDTO("a", "a", 1) } }; var multiAssign1 = new DsfMultiAssignActivity() { UniqueID = uniqueId, FieldsCollection = new List <ActivityDTO>() { new ActivityDTO("a", "a", 1) } }; //---------------Assert Precondition---------------- Assert.IsTrue(multiAssign.Equals(multiAssign1)); //---------------Execute Test ---------------------- multiAssign.UpdateAllOccurrences = true; multiAssign1.UpdateAllOccurrences = true; var equals = multiAssign.Equals(multiAssign1); //---------------Test Result ----------------------- Assert.IsTrue(equals); }
protected override void BuildDataList() { var variableList = scenarioContext.Get <List <Tuple <string, string> > >("variableList"); variableList.Add(new Tuple <string, string>(ResultVariable, "")); BuildShapeAndTestData(); var flowSwitch = new DsfFlowSwitchActivity { ExpressionText = string.Format( "Dev2.Data.Decision.Dev2DataListDecisionHandler.Instance.FetchSwitchData(\"{0}\",AmbientDataList)", variableList.First().Item1), }; var sw = new FlowSwitch <string>(); sw.Expression = flowSwitch; var multiAssign = new DsfMultiAssignActivity(); int row = 1; foreach (var variable in variableList) { multiAssign.FieldsCollection.Add(new ActivityDTO(variable.Item1, variable.Item2, row, true)); row++; } TestStartNode = new FlowStep { Action = multiAssign, Next = sw }; scenarioContext.Add("activity", flowSwitch); }
public void RowToIndexConverter_Convert_FindsValue_ReturnsIndex() { //------------Setup for test-------------------------- var converter = new RowToIndexConverter(); var activityDtos = new List <ActivityDTO> { new ActivityDTO("name", "value", 0), new ActivityDTO("name1", "value1", 1), new ActivityDTO("name2", "value2", 2) }; var multiAssign = new DsfMultiAssignActivity(); multiAssign.FieldsCollection = activityDtos; dynamic modelItem = ModelItemUtils.CreateModelItem(multiAssign); //------------Execute Test--------------------------- if (modelItem.FieldsCollection is ModelItemCollection collection) { var result = converter.Convert(collection[1], typeof(int), null, CultureInfo.CurrentCulture); //------------Assert Results------------------------- Assert.AreEqual(2, result); } else { Assert.Fail(); } }
public void SequenceActivityFindMissingStrategy_GetActivityFields_WithAssignAndDecision_ReturnsAllVariables() { //------------Setup for test-------------------------- var multiAssignActivity = new DsfMultiAssignActivity { FieldsCollection = new List <ActivityDTO> { new ActivityDTO("[[AssignRight1]]", "[[AssignLeft1]]", 1), new ActivityDTO("[[AssignRight2]]", "[[AssignLeft2]]", 2) } }; var decisionActivity = new DsfFlowDecisionActivity { OnErrorVariable = "[[error]]" }; var activity = new DsfSequenceActivity(); activity.Activities.Add(multiAssignActivity); activity.Activities.Add(decisionActivity); var fac = new Dev2FindMissingStrategyFactory(); var strategy = fac.CreateFindMissingStrategy(enFindMissingType.Sequence); //------------Execute Test--------------------------- var actual = strategy.GetActivityFields(activity); //------------Assert Results------------------------- var expected = new List <string> { "[[AssignRight1]]", "[[AssignLeft1]]", "[[AssignRight2]]", "[[AssignLeft2]]", "[[error]]" }; CollectionAssert.AreEqual(expected, actual); }
public void SequenceDesignerViewModel_SetModelItemForServiceTypes_HasExplorerItemInDataObject_Adds() { //------------Setup for test-------------------------- var dsfSequenceActivity = new DsfSequenceActivity(); var dsfMultiAssignActivity = new DsfMultiAssignActivity(); dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity); var resource = new Mock <IContextualResourceModel>(); resource.Setup(r => r.ServerResourceType).Returns(""); var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity)); var mockServerRepo = new Mock <IServerRepository>(); var serverMock = new Mock <IServer>(); var resourceRepoMock = new Mock <IResourceRepository>(); resourceRepoMock.Setup(rr => rr.LoadContextualResourceModel(It.IsAny <Guid>())).Returns(resource.Object); serverMock.Setup(s => s.ResourceRepository).Returns(resourceRepoMock.Object); mockServerRepo.Setup(sr => sr.FindSingle(It.IsAny <System.Linq.Expressions.Expression <Func <IServer, bool> > >())).Returns(serverMock.Object); sequenceDesignerViewModel.ServerRepository = mockServerRepo.Object; var mockExpViewModel = new Mock <IExplorerItemViewModel>(); mockExpViewModel.Setup(ex => ex.Server).Returns(serverMock.Object); mockExpViewModel.Setup(ex => ex.ResourceId).Returns(resource.Object.ID); var dataObject = new DataObject(GlobalConstants.UpgradedExplorerItemModelFormat, mockExpViewModel.Object); //------------Execute Test--------------------------- sequenceDesignerViewModel.TrySetModelItemForServiceTypes(dataObject); //------------Assert Results------------------------- var dataPresent = dataObject.GetDataPresent(DragDropHelper.ModelItemDataFormat); Assert.IsFalse(dataPresent); }
public void RowToIndexConverter_Convert_DoesntFindValue_ReturnsMinusOne() { var converter = new RowToIndexConverter(); var activityDtos = new List <ActivityDTO> { new ActivityDTO("name", "value", 0), new ActivityDTO("name1", "value1", 1), new ActivityDTO("name2", "value2", 2) }; var multiAssign = new DsfMultiAssignActivity(); multiAssign.FieldsCollection = activityDtos; var modelItemThatdoesntExist = ModelItemUtils.CreateModelItem(new ActivityDTO("thing", "stuff", 8)); dynamic modelItem = ModelItemUtils.CreateModelItem(multiAssign); //------------Execute Test--------------------------- if (modelItem.FieldsCollection is ModelItemCollection collection) { var result = converter.Convert(modelItemThatdoesntExist, typeof(int), null, CultureInfo.CurrentCulture); //------------Assert Results------------------------- Assert.AreEqual(-1, result); } else { Assert.Fail(); } }
public void RowToIndexConverter_Convert_DoesntFindValue_ReturnsMinusOne() { var converter = new RowToIndexConverter(); var activityDtos = new List<ActivityDTO> { new ActivityDTO("name", "value", 0), new ActivityDTO("name1", "value1", 1), new ActivityDTO("name2", "value2", 2) }; DsfMultiAssignActivity multiAssign = new DsfMultiAssignActivity(); multiAssign.FieldsCollection = activityDtos; ModelItem modelItemThatdoesntExist = ModelItemUtils.CreateModelItem(new ActivityDTO("thing", "stuff", 8)); dynamic modelItem = ModelItemUtils.CreateModelItem(multiAssign); ModelItemCollection collection = modelItem.FieldsCollection as ModelItemCollection; //------------Execute Test--------------------------- if(collection != null) { var result = converter.Convert(modelItemThatdoesntExist, typeof(int), null, CultureInfo.CurrentCulture); //------------Assert Results------------------------- Assert.AreEqual(-1, result); } else { Assert.Fail(); } }
public void RedisCacheActivityFindMissingStrategy_GetActivityFields_CheckRedisCacheActivityWithDsfMultiAssignActivity_ExpectedAllFindMissingFieldsToBeReturned() { //--------------Arrange------------------------------ var multiAssignActivity = new DsfMultiAssignActivity { FieldsCollection = new List <ActivityDTO> { new ActivityDTO("[[AssignRight1]]", "[[AssignLeft1]]", 1), new ActivityDTO("[[AssignRight2]]", "[[AssignLeft2]]", 2) } }; var activity = new RedisCacheActivity { DisplayName = "Redis Cache", ActivityFunc = { Handler = multiAssignActivity } }; var findMissingStrategyFactory = new Dev2FindMissingStrategyFactory(); var strategy = findMissingStrategyFactory.CreateFindMissingStrategy(enFindMissingType.RedisCache); //--------------Act---------------------------------- var actual = strategy.GetActivityFields(activity); //--------------Assert------------------------------- var expected = new List <string> { "[[AssignRight1]]", "[[AssignLeft1]]", "[[AssignRight2]]", "[[AssignLeft2]]", "5" }; CollectionAssert.AreEqual(expected, actual); }
public void Equals_Given_SameSwitches_DifferentIndexes_SwitchActivity_AreNotEqual() { //---------------Set up test pack------------------- var uniqId = Guid.NewGuid().ToString(); var assign = new DsfMultiAssignActivity(); var switches = new Dictionary <string, IDev2Activity> { { "Arm2", assign }, { "Arm", assign } }; var switches2 = new Dictionary <string, IDev2Activity> { { "Arm", assign }, { "Arm2", assign } }; var activity = new DsfSwitch { UniqueID = uniqId, Switches = switches }; var activity1 = new DsfSwitch { UniqueID = uniqId, Switches = switches2 }; //---------------Assert Precondition---------------- Assert.IsNotNull(activity); //---------------Execute Test ---------------------- var @equals = activity.Equals(activity1); //---------------Test Result ----------------------- Assert.IsTrue(@equals); }
public void FieldsCollectionSame_EmptyAssigns_IsNotEqual_CaseSensitive() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var multiAssign = new DsfMultiAssignActivity() { UniqueID = uniqueId, FieldsCollection = new List <ActivityDTO>() { new ActivityDTO("A", "a", 1) } }; var multiAssign1 = new DsfMultiAssignActivity() { UniqueID = uniqueId, FieldsCollection = new List <ActivityDTO>() { new ActivityDTO("a", "a", 1) } }; //---------------Assert Precondition---------------- Assert.IsNotNull(multiAssign); //---------------Execute Test ---------------------- var equals = multiAssign.Equals(multiAssign1); //---------------Test Result ----------------------- Assert.IsFalse(equals); }
public void CreateBookmark_Same_Object_Is_Not_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var multiAssign = new DsfMultiAssignActivity() { UniqueID = uniqueId, FieldsCollection = new List <ActivityDTO>() { new ActivityDTO("a", "a", 1) }, CreateBookmark = false }; var multiAssign1 = new DsfMultiAssignActivity() { UniqueID = uniqueId, FieldsCollection = new List <ActivityDTO>() { new ActivityDTO("a", "a", 1) }, CreateBookmark = false }; //---------------Assert Precondition---------------- Assert.IsTrue(multiAssign.Equals(multiAssign1)); //---------------Execute Test ---------------------- multiAssign.CreateBookmark = true; var equals = multiAssign.Equals(multiAssign1); //---------------Test Result ----------------------- Assert.IsFalse(equals); }
public void DsfMultiAssignActivity_UpdateForEachInputs_WhenContainsMatchingStarAndOtherData_UpdateSuccessful() { //------------Setup for test-------------------------- var fieldsCollection = new List <ActivityDTO> { new ActivityDTO("[[result]]", "[[rs(*).val]] [[result]]", 1), }; var act = new DsfMultiAssignActivity { FieldsCollection = fieldsCollection }; //------------Execute Test--------------------------- act.UpdateForEachInputs(new List <Tuple <string, string> > { new Tuple <string, string>("[[rs(*).val]]", "[[rs(1).val]]"), }); //------------Assert Results------------------------- var collection = act.FieldsCollection; Assert.AreEqual("[[rs(1).val]] [[result]]", collection[0].FieldValue); }
public void GivenContainsAnAssignAs(string parentName, string assignName, Table table) { var assignActivity = new DsfMultiAssignActivity { DisplayName = assignName }; foreach (var tableRow in table.Rows) { var value = tableRow["value"]; var variable = tableRow["variable"]; value = value.Replace('"', ' ').Trim(); if (value.StartsWith("=")) { value = value.Replace("=", ""); value = string.Format("!~calculation~!{0}!~~calculation~!", value); } scenarioContext.TryGetValue("fieldCollection", out List <ActivityDTO> fieldCollection); _commonSteps.AddVariableToVariableList(variable); assignActivity.FieldsCollection.Add(new ActivityDTO(variable, value, 1, true)); } _commonSteps.AddActivityToActivityList(parentName, assignName, assignActivity); }
public void RedisCacheIntegration_CacheVariableResult_GetDebugInputs_With_DataListUtilIsEvaluated_ShouldReturnInnerActivityOutputs() { try { //----------------------Arrange---------------------- var key = "key" + Guid.NewGuid(); TestAnonymousAuth(out string hostName, out string password, out int port); var redisSource = new RedisSource { HostName = hostName, Password = password, Port = port.ToString() }; var isCalValue = GlobalConstants.CalculateTextConvertPrefix + "rec(*).name" + GlobalConstants.CalculateTextConvertSuffix; var innerActivity = new DsfMultiAssignActivity() { FieldsCollection = new List <ActivityDTO> { new ActivityDTO("[[objectId1]]", "ObjectName1", 1), new ActivityDTO("[[objectId2]]", "ObjectName2", 2), new ActivityDTO(isCalValue, "ObjectName3", 3) } }; GenerateMocks(key, redisSource, out Mock <IResourceCatalog> mockResourceCatalog, out Mock <IDSFDataObject> mockDataObject); CreateRedisActivity(key, hostName, port, password, mockResourceCatalog, out TestRedisActivity sut, innerActivity); //----------------------Act-------------------------- sut.TestExecuteTool(mockDataObject.Object); var debugInputs = sut.GetDebugOutputs(mockDataObject.Object.Environment, 0); //----------------------Assert----------------------- var actualInnerActivity = sut.ActivityFunc.Handler; Assert.AreEqual("Assign", actualInnerActivity.DisplayName); Assert.IsTrue(debugInputs is List <DebugItem>, "Debug inputs must return List<DebugItem>"); Assert.AreEqual(4, debugInputs.Count); Assert.AreEqual(1, debugInputs[0].ResultsList.Count); AssertDebugItems(debugInputs, 0, 0, "Redis key { " + sut.Key + " } not found", null, "", ""); AssertDebugItems(debugInputs, 1, 0, "1", null, "", ""); AssertDebugItems(debugInputs, 1, 1, null, "[[objectId1]]", "=", "ObjectName1"); AssertDebugItems(debugInputs, 2, 0, "1", null, "", ""); AssertDebugItems(debugInputs, 2, 1, null, "[[objectId2]]", "=", "ObjectName2"); AssertDebugItems(debugInputs, 3, 0, "1", null, "", ""); } catch (Exception e) { if (e.Message.Contains("could not connect to redis Instance")) { Assert.Inconclusive(e.Message); } else { throw; } } }
protected override void BuildDataList() { BuildShapeAndTestData(); var decisionActivity = new DsfFlowDecisionActivity(); scenarioContext.TryGetValue("mode", out Dev2DecisionMode mode); var decisionModels = scenarioContext.Get <List <Tuple <string, enDecisionType, string, string> > >("decisionModels"); var dds = new Dev2DecisionStack { TheStack = new List <Dev2Decision>(), Mode = mode, TrueArmText = "YES", FalseArmText = "NO" }; foreach (var dm in decisionModels) { var dev2Decision = new Dev2Decision { Col1 = dm.Item1 ?? string.Empty, EvaluationFn = dm.Item2, Col2 = dm.Item3 ?? string.Empty, Col3 = dm.Item4 ?? string.Empty }; dds.AddModelItem(dev2Decision); } var modelData = dds.ToVBPersistableModel(); scenarioContext.Add("modelData", modelData); decisionActivity.ExpressionText = string.Join("", GlobalConstants.InjectedDecisionHandler, "(\"", modelData, "\",", GlobalConstants.InjectedDecisionDataListVariable, ")"); scenarioContext.TryGetValue("variableList", out List <Tuple <string, string> > variableList); if (variableList == null) { variableList = new List <Tuple <string, string> >(); scenarioContext.Add("variableList", variableList); } var multiAssign = new DsfMultiAssignActivity(); var row = 1; foreach (var variable in variableList) { multiAssign.FieldsCollection.Add(new ActivityDTO(variable.Item1, variable.Item2, row, true)); row++; } var x = new FlowDecision(); x.Condition = decisionActivity; TestStartNode = new FlowStep { Action = multiAssign, Next = x }; scenarioContext.Add("activity", decisionActivity); }
public void SequenceDesignerViewModel_ActivityNames_When4_HasAllNames() { //------------Setup for test-------------------------- var dsfSequenceActivity = new DsfSequenceActivity(); var dsfMultiAssignActivity = new DsfMultiAssignActivity(); dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity); var dsfFindRecordsMultipleCriteriaActivity = new DsfFindRecordsMultipleCriteriaActivity(); dsfSequenceActivity.Activities.Add(dsfFindRecordsMultipleCriteriaActivity); var dsfGatherSystemInformationActivity = new DsfGatherSystemInformationActivity(); dsfSequenceActivity.Activities.Add(dsfGatherSystemInformationActivity); var dsfBaseConvertActivity = new DsfBaseConvertActivity(); dsfSequenceActivity.Activities.Add(dsfBaseConvertActivity); var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity)); //------------Execute Test--------------------------- var activityNames = sequenceDesignerViewModel.ActivityNames; //------------Assert Results------------------------- Assert.AreEqual(4, activityNames.Count); Assert.AreEqual(dsfMultiAssignActivity.DisplayName, activityNames[0]); Assert.AreEqual(dsfFindRecordsMultipleCriteriaActivity.DisplayName, activityNames[1]); Assert.AreEqual(dsfGatherSystemInformationActivity.DisplayName, activityNames[2]); Assert.AreEqual(dsfBaseConvertActivity.DisplayName, activityNames[3]); }
public void RowToIndexConverter_Convert_FindsValue_ReturnsIndex() { //------------Setup for test-------------------------- var converter = new RowToIndexConverter(); var activityDtos = new List<ActivityDTO> { new ActivityDTO("name", "value", 0), new ActivityDTO("name1", "value1", 1), new ActivityDTO("name2", "value2", 2) }; DsfMultiAssignActivity multiAssign = new DsfMultiAssignActivity(); multiAssign.FieldsCollection = activityDtos; dynamic modelItem = ModelItemUtils.CreateModelItem(multiAssign); ModelItemCollection collection = modelItem.FieldsCollection as ModelItemCollection; //------------Execute Test--------------------------- if(collection != null) { var result = converter.Convert(collection[1], typeof(int), null, CultureInfo.CurrentCulture); //------------Assert Results------------------------- Assert.AreEqual(2, result); } else { Assert.Fail(); } }
protected override void BuildDataList() { var variableList = ScenarioContext.Current.Get<List<Tuple<string, string>>>("variableList"); variableList.Add(new Tuple<string, string>(ResultVariable, "")); BuildShapeAndTestData(); var flowSwitch = new DsfFlowSwitchActivity { ExpressionText = string.Format( "Dev2.Data.Decision.Dev2DataListDecisionHandler.Instance.FetchSwitchData(\"{0}\",AmbientDataList)", variableList.First().Item1), }; var sw = new FlowSwitch<string>(); sw.Expression = flowSwitch; var multiAssign = new DsfMultiAssignActivity(); int row = 1; foreach(var variable in variableList) { multiAssign.FieldsCollection.Add(new ActivityDTO(variable.Item1, variable.Item2, row, true)); row++; } TestStartNode = new FlowStep { Action = multiAssign, Next = sw }; ScenarioContext.Current.Add("activity", flowSwitch); }
public void GivenContainsAnAssignAs(string parentName, string assignName, Table table) { DsfMultiAssignActivity assignActivity = new DsfMultiAssignActivity { DisplayName = assignName }; foreach(var tableRow in table.Rows) { var value = tableRow["value"]; var variable = tableRow["variable"]; value = value.Replace('"', ' ').Trim(); if(value.StartsWith("=")) { value = value.Replace("=", ""); value = string.Format("!~calculation~!{0}!~~calculation~!", value); } List<ActivityDTO> fieldCollection; ScenarioContext.Current.TryGetValue("fieldCollection", out fieldCollection); CommonSteps.AddVariableToVariableList(variable); assignActivity.FieldsCollection.Add(new ActivityDTO(variable, value, 1, true)); } CommonSteps.AddActivityToActivityList(parentName, assignName, assignActivity); }
public void GetDataList_GivenEmptyResourceModel_ShouldReturnReturnEmpty() { //------------Setup for test-------------------------- var adapter = new Mock <IApplicationAdaptor>(); adapter.Setup(p => p.TryFindResource(It.IsAny <object>())).Returns(new object()); CustomContainer.Register(adapter.Object); var node = new Mock <IConflictTreeNode>(); var contextualResource = new Mock <IContextualResourceModel>(); var value = new DsfMultiAssignActivity(); var assignStep = new FlowStep { Action = value }; node.Setup(p => p.Activity).Returns(value); var assignExample = XML.XmlResource.Fetch("AssignOutput"); var jsonSerializer = new Dev2JsonSerializer(); var currentResourceModel = Dev2MockFactory.SetupResourceModelMock(); var assignExampleBuilder = new StringBuilder(assignExample.ToString(System.Xml.Linq.SaveOptions.DisableFormatting)); currentResourceModel.Setup(resModel => resModel.WorkflowXaml).Returns(assignExampleBuilder); currentResourceModel.Setup(resModel => resModel.DisplayName).Returns("Hello World"); currentResourceModel.Setup(resModel => resModel.DataList).Returns(""); var toolConflictItem = new ToolConflictItem(new ViewModels.Merge.Utils.ConflictRowList(new Mock <IConflictModelFactory>().Object, new Mock <IConflictModelFactory>().Object, new List <ConflictTreeNode>(), new List <ConflictTreeNode>()), ViewModels.Merge.Utils.ConflictRowList.Column.Current); //------------Execute Test--------------------------- var completeConflict = new ConflictModelFactory(toolConflictItem, contextualResource.Object, node.Object); //------------Assert Results------------------------- Assert.IsNotNull(completeConflict); completeConflict.GetDataList(currentResourceModel.Object); Assert.AreEqual(2, completeConflict.DataListViewModel.DataList.Count); }
public void FieldsCollectionSameDifferentIndexNumbers_EmptyAssigns_Is_Not_Equal() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var multiAssign = new DsfMultiAssignActivity() { UniqueID = uniqueId, FieldsCollection = new List <ActivityDTO>() { new ActivityDTO("a", "a", 1), new ActivityDTO("B", "B", 2), } }; var multiAssign1 = new DsfMultiAssignActivity() { UniqueID = uniqueId, FieldsCollection = new List <ActivityDTO>() { new ActivityDTO("B", "B", 1), new ActivityDTO("a", "a", 2) } }; //---------------Assert Precondition---------------- Assert.IsNotNull(multiAssign); //---------------Execute Test ---------------------- var @equals = multiAssign.Equals(multiAssign1); //---------------Test Result ----------------------- Assert.IsFalse(equals); }
public void GetActivityFieldsOffMultiAssignActivityExpectedAllFindMissingFieldsToBeReturned() { DsfMultiAssignActivity multiAssignActivity = new DsfMultiAssignActivity { FieldsCollection = new List<ActivityDTO> { new ActivityDTO("[[AssignRight1]]", "[[AssignLeft1]]", 1), new ActivityDTO("[[AssignRight2]]", "[[AssignLeft2]]", 2) } }; Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory(); IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.DataGridActivity); List<string> actual = strategy.GetActivityFields(multiAssignActivity); List<string> expected = new List<string> { "[[AssignRight1]]", "[[AssignLeft1]]", "[[AssignRight2]]", "[[AssignLeft2]]" }; CollectionAssert.AreEqual(expected, actual); }
public void RedisCacheIntegration_CacheVariableResult_EvaluateVariableAsKey() { try { var key = "[[RedisKey]]"; var keyValue = "someval" + Guid.NewGuid(); TestAnonymousAuth(out string hostName, out string password, out int port); var redisSource = new RedisSource { HostName = hostName, Password = password, Port = port.ToString() }; var innerActivity = new DsfMultiAssignActivity() { FieldsCollection = new List <ActivityDTO> { new ActivityDTO("[[objectId1]]", "ObjectName1", 1), new ActivityDTO("[[objectId2]]", "ObjectName2", 2) } }; var mockResourceCatalog = new Mock <IResourceCatalog>(); var mockDataObject = new Mock <IDSFDataObject>(); var environment = new ExecutionEnvironment(); environment.Assign(key, keyValue, 0); var env = new Mock <IExecutionEnvironment>(); env.Setup(e => e.EvalToExpression(It.IsAny <string>(), It.IsAny <int>())).Returns(key); mockResourceCatalog.Setup(o => o.GetResource <RedisSource>(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(redisSource); mockDataObject.Setup(o => o.IsDebugMode()).Returns(true); mockDataObject.Setup(o => o.Environment).Returns(environment); CreateRedisActivity(key, hostName, port, password, mockResourceCatalog, out TestRedisActivity sut, innerActivity); //----------------------Act-------------------------- sut.TestExecuteTool(mockDataObject.Object); var debugOutputs = sut.GetDebugOutputs(mockDataObject.Object.Environment, 0); //----------------------Assert----------------------- Assert.AreEqual(3, debugOutputs.Count); Assert.AreEqual(1, debugOutputs[0].ResultsList.Count); AssertDebugItems(debugOutputs, 0, 0, "Redis key { " + keyValue + " } not found", null, "", ""); AssertDebugItems(debugOutputs, 1, 0, "1", null, "", ""); AssertDebugItems(debugOutputs, 1, 1, null, "[[objectId1]]", "=", "ObjectName1"); AssertDebugItems(debugOutputs, 2, 0, "1", null, "", ""); AssertDebugItems(debugOutputs, 2, 1, null, "[[objectId2]]", "=", "ObjectName2"); } catch (Exception e) { if (e.Message.Contains("could not connect to redis Instance")) { Assert.Inconclusive(e.Message); } else { throw; } } }
protected override void BuildDataList() { BuildShapeAndTestData(); var decisionActivity = new DsfFlowDecisionActivity(); Dev2DecisionMode mode; ScenarioContext.Current.TryGetValue("mode", out mode); var decisionModels = ScenarioContext.Current.Get<List<Tuple<string, enDecisionType, string, string>>>("decisionModels"); var dds = new Dev2DecisionStack { TheStack = new List<Dev2Decision>(), Mode = mode, TrueArmText = "YES", FalseArmText = "NO" }; foreach(var dm in decisionModels) { var dev2Decision = new Dev2Decision { Col1 = dm.Item1 ?? string.Empty, EvaluationFn = dm.Item2, Col2 = dm.Item3 ?? string.Empty, Col3 = dm.Item4 ?? string.Empty }; dds.AddModelItem(dev2Decision); } string modelData = dds.ToVBPersistableModel(); ScenarioContext.Current.Add("modelData", modelData); decisionActivity.ExpressionText = string.Join("", GlobalConstants.InjectedDecisionHandler, "(\"", modelData, "\",", GlobalConstants.InjectedDecisionDataListVariable, ")"); List<Tuple<string, string>> variableList; ScenarioContext.Current.TryGetValue("variableList", out variableList); if(variableList == null) { variableList = new List<Tuple<string, string>>(); ScenarioContext.Current.Add("variableList", variableList); } var multiAssign = new DsfMultiAssignActivity(); int row = 1; foreach(var variable in variableList) { multiAssign.FieldsCollection.Add(new ActivityDTO(variable.Item1, variable.Item2, row, true)); row++; } FlowDecision x = new FlowDecision(); x.Condition=decisionActivity; TestStartNode = new FlowStep { Action = multiAssign, Next = x }; ScenarioContext.Current.Add("activity", decisionActivity); }
public void RedisActivity_GetDebugInputs_ShouldReturnInnerActivityOutputs() { //----------------------Arrange---------------------- try { //----------------------Arrange---------------------- TestAnonymousAuth(new Depends(Depends.ContainerType.AnonymousRedis), out string key, out string hostName, out string password, out int port); var redisSource = new RedisSource { HostName = hostName, Password = password, Port = port.ToString() }; var innerActivity = new DsfMultiAssignActivity() { FieldsCollection = new List <ActivityDTO> { new ActivityDTO("[[objectId1]]", "ObjectName1", 1), new ActivityDTO("[[objectId2]]", "ObjectName2", 2) } }; GenerateMocks(key, redisSource, out Mock <IResourceCatalog> mockResourceCatalog, out Mock <IDSFDataObject> mockDataObject); GenerateSUTInstance(key, hostName, port, password, mockResourceCatalog, out Dictionary <string, string> evel, out TestRedisActivity sut, innerActivity); //----------------------Act-------------------------- sut.TestExecuteTool(mockDataObject.Object); sut.TestPerformExecution(evel); var debugInputs = sut.GetDebugInputs(mockDataObject.Object.Environment, 0); //----------------------Assert----------------------- var actualInnerActivity = sut.ActivityFunc.Handler; Assert.AreEqual("Assign", actualInnerActivity.DisplayName); Assert.IsTrue(debugInputs is List <DebugItem>, "Debug inputs must return List<DebugItem>"); Assert.AreEqual(4, debugInputs.Count); Assert.AreEqual(1, debugInputs[0].ResultsList.Count); AssertDebugItems(debugInputs, 0, 0, "Key", null, "=", sut.Key); AssertDebugItems(debugInputs, 1, 0, "Redis key { " + sut.Key + " } not found", null, "", ""); AssertDebugItems(debugInputs, 2, 0, "1", null, "", ""); AssertDebugItems(debugInputs, 2, 1, null, "[[objectId1]]", "=", "ObjectName1"); AssertDebugItems(debugInputs, 3, 0, "2", null, "", ""); AssertDebugItems(debugInputs, 3, 1, null, "[[objectId2]]", "=", "ObjectName2"); } catch (Exception e) { if (e.Message.Contains("could not connect to redis Instance")) { Assert.Inconclusive(e.Message); } else { throw; } } }
public void RedisRemoveIntegration_UseVariableAsKey() { try { var redisSource = TestRedisSource(out var hostName, out var password, out var port); var key = "[[RedisKey]]"; var keyValue = "someval" + Guid.NewGuid(); var innerActivity = new DsfMultiAssignActivity() { FieldsCollection = new List <ActivityDTO> { new ActivityDTO("[[objectId1]]", "ObjectName1", 1), new ActivityDTO("[[objectId2]]", "ObjectName2", 2) } }; var mockResourceCatalog = new Mock <IResourceCatalog>(); mockResourceCatalog.Setup(o => o.GetResource <RedisSource>(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(redisSource); var environment = new ExecutionEnvironment(); environment.Assign(key, keyValue, 0); var mockDataObject = new Mock <IDSFDataObject>(); mockDataObject.Setup(o => o.IsDebugMode()).Returns(true); mockDataObject.Setup(o => o.Environment).Returns(environment); //--create key GenerateAddKeyInstance(key, hostName, port, password, mockResourceCatalog, out Dictionary <string, string> evalAdd, out TestRedisActivity sutAdd, innerActivity); //----------------------Act-------------------------- sutAdd.TestExecuteTool(mockDataObject.Object); sutAdd.TestPerformExecution(evalAdd); //--Remove Key GenerateRemoveKeyInstance(key, hostName, port, password, mockResourceCatalog, out TestRedisRemoveActivity sutRemove); //----------------------Act-------------------------- mockDataObject.Setup(o => o.IsDebugMode()).Returns(true); mockDataObject.Setup(o => o.Environment).Returns(environment); sutRemove.TestExecuteTool(mockDataObject.Object); Assert.AreEqual(sutRemove.Key, key); Assert.AreEqual("Success", sutRemove.Response); sutRemove.TestExecuteTool(mockDataObject.Object); Assert.AreEqual("Failure", sutRemove.Response); } catch (Exception e) { if (e.Message.Contains("could not connect to redis Instance")) { Assert.Inconclusive(e.Message); } else { throw; } } }
public void GetActivityFieldsOffDsfForEachActivityWithADsfMultiAssignActivityInsideItExpectedAllFindMissingFieldsToBeReturned() { DsfMultiAssignActivity multiAssignActivity = new DsfMultiAssignActivity { FieldsCollection = new List<ActivityDTO> { new ActivityDTO("[[AssignRight1]]", "[[AssignLeft1]]", 1), new ActivityDTO("[[AssignRight2]]", "[[AssignLeft2]]", 2) } }; DsfForEachActivity activity = new DsfForEachActivity { ForEachElementName = "5", DataFunc = { Handler = multiAssignActivity } }; Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory(); IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.ForEach); List<string> actual = strategy.GetActivityFields(activity); List<string> expected = new List<string> { "[[AssignRight1]]", "[[AssignLeft1]]", "[[AssignRight2]]", "[[AssignLeft2]]", "5" }; CollectionAssert.AreEqual(expected, actual); }
public void SequenceDesignerViewModel_SetModelItemForServiceTypes_DataObjectNull_NothingAddedToDataObject() { //------------Setup for test-------------------------- var dsfSequenceActivity = new DsfSequenceActivity(); var dsfMultiAssignActivity = new DsfMultiAssignActivity(); dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity); var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity)); //------------Execute Test--------------------------- var modelItemForServiceTypes = sequenceDesignerViewModel.SetModelItemForServiceTypes(null); //------------Assert Results------------------------- Assert.IsFalse(modelItemForServiceTypes); }
public void UniqueIDDifferent_EmptyAssigns_IsEqual() { //---------------Set up test pack------------------- var uniqueId = Guid.NewGuid().ToString(); var multiAssign = new DsfMultiAssignActivity(); var multiAssign1 = new DsfMultiAssignActivity(); //---------------Assert Precondition---------------- Assert.IsNotNull(multiAssign); //---------------Execute Test ---------------------- var @equals = multiAssign.Equals(multiAssign1); //---------------Test Result ----------------------- Assert.IsFalse(equals); }
public void ForEachDesignerViewModel_MultipleItems_ModelItemsFormatListOfModelItemContainsOneActivity_NotAddedToSequence() { //------------Setup for test-------------------------- var modelItem = CreateModelItem(); var viewModel = new ForeachDesignerViewModel(modelItem); var assignActivity = new DsfMultiAssignActivity(); var dataObject = new DataObject("ModelItemsFormat", new List <ModelItem> { ModelItemUtils.CreateModelItem(assignActivity) }); //------------Execute Test--------------------------- bool multipleItemsToSequence = viewModel.MultipleItemsToSequence(dataObject); //------------Assert Results------------------------- Assert.IsFalse(multipleItemsToSequence); }
public void RedisActivity_GetDebugOutputs_ShouldReturnInnerActivityOutputs_TTLReached() { //----------------------Arrange---------------------- TestAnonymousAuth(out string key, out string hostName, out string password, out int port); var redisSource = new RedisSource { HostName = hostName, Password = password, Port = port.ToString() }; var innerActivity = new DsfMultiAssignActivity() { FieldsCollection = new List <ActivityDTO> { new ActivityDTO("[[objectId1]]", "ObjectName1", 1), new ActivityDTO("[[objectId2]]", "ObjectName2", 2) } }; GenerateMocks(key, redisSource, out Mock <IResourceCatalog> mockResourceCatalog, out Mock <IDSFDataObject> mockDataObject); GenerateSUTInstance(key, hostName, port, password, mockResourceCatalog, out Dictionary <string, string> evel, out TestRedisActivity sut, innerActivity); //----------------------Act-------------------------- sut.TestExecuteTool(mockDataObject.Object); sut.TestPerformExecution(evel); var timer = new Stopwatch(); timer.Start(); do { Thread.Sleep(1000); } while (timer.Elapsed < TimeSpan.FromMilliseconds(sut.TTL)); timer.Stop(); var debugOutputs = sut.GetDebugOutputs(mockDataObject.Object.Environment, 0); //----------------------Assert----------------------- var actualInnerActivity = sut.ActivityFunc.Handler; Assert.AreEqual("Assign", actualInnerActivity.DisplayName); Assert.IsTrue(debugOutputs is List <DebugItem>, "Debug inputs must return List<DebugItem>"); Assert.AreEqual(3, debugOutputs.Count); Assert.AreEqual(1, debugOutputs[0].ResultsList.Count); AssertDebugItems(debugOutputs, 0, 0, "Redis key { " + sut.Key + " } found", null, "", ""); AssertDebugItems(debugOutputs, 1, 0, "1", null, "", ""); AssertDebugItems(debugOutputs, 1, 1, null, "[[objectId1]]", "=", "ObjectName1"); AssertDebugItems(debugOutputs, 2, 0, "2", null, "", ""); AssertDebugItems(debugOutputs, 2, 1, null, "[[objectId2]]", "=", "ObjectName2"); }
public void GetActivityFieldsOffMultiAssignActivityExpectedAllFindMissingFieldsToBeReturned() { DsfMultiAssignActivity multiAssignActivity = new DsfMultiAssignActivity(); multiAssignActivity.FieldsCollection = new List <ActivityDTO> { new ActivityDTO("[[AssignRight1]]", "[[AssignLeft1]]", 1), new ActivityDTO("[[AssignRight2]]", "[[AssignLeft2]]", 2) }; Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory(); IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.DataGridActivity); List <string> actual = strategy.GetActivityFields(multiAssignActivity); List <string> expected = new List <string> { "[[AssignRight1]]", "[[AssignLeft1]]", "[[AssignRight2]]", "[[AssignLeft2]]" }; CollectionAssert.AreEqual(expected, actual); }
public void SequenceDesignerViewModel_SetModelItemForServiceTypes_DataHaveDataContextNotResourceModel_NothingAddedToDataObject() { //------------Setup for test-------------------------- var dsfSequenceActivity = new DsfSequenceActivity(); var dsfMultiAssignActivity = new DsfMultiAssignActivity(); dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity); var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity)); var dataObject = new DataObject(GlobalConstants.ExplorerItemModelFormat, new TestDataWithContext()); //------------Execute Test--------------------------- sequenceDesignerViewModel.SetModelItemForServiceTypes(dataObject); //------------Assert Results------------------------- bool dataPresent = dataObject.GetDataPresent(DragDropHelper.ModelItemDataFormat); Assert.IsFalse(dataPresent); }
public void SequenceDesignerViewModel_SetModelItemForServiceTypes_Data_NothingAddedToDataObject() { //------------Setup for test-------------------------- var dsfSequenceActivity = new DsfSequenceActivity(); var dsfMultiAssignActivity = new DsfMultiAssignActivity(); dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity); var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity)); var dataObject = new DataObject("Some Wrong Format", new object()); //------------Execute Test--------------------------- sequenceDesignerViewModel.SetModelItemForServiceTypes(dataObject); //------------Assert Results------------------------- bool dataPresent = dataObject.GetDataPresent(DragDropHelper.ModelItemDataFormat); Assert.IsFalse(dataPresent); }
public void RedisActivity_GetDebugInputs_With_DataListUtilIsEvaluated_ShouldReturnInnerActivityOutputs() { //----------------------Arrange---------------------- TestAnonymousAuth(out string key, out string hostName, out string password, out int port); var redisSource = new RedisSource { HostName = hostName, Password = password, Port = port.ToString() }; var isCalValue = GlobalConstants.CalculateTextConvertPrefix + "rec(*).name" + GlobalConstants.CalculateTextConvertSuffix; var innerActivity = new DsfMultiAssignActivity() { FieldsCollection = new List <ActivityDTO> { new ActivityDTO("[[objectId1]]", "ObjectName1", 1), new ActivityDTO("[[objectId2]]", "ObjectName2", 2), new ActivityDTO(isCalValue, "ObjectName3", 3) } }; GenerateMocks(key, redisSource, out Mock <IResourceCatalog> mockResourceCatalog, out Mock <IDSFDataObject> mockDataObject); GenerateSUTInstance(key, hostName, port, password, mockResourceCatalog, out Dictionary <string, string> evel, out TestRedisActivity sut, innerActivity); //----------------------Act-------------------------- sut.TestExecuteTool(mockDataObject.Object); sut.TestPerformExecution(evel); var debugInputs = sut.GetDebugInputs(mockDataObject.Object.Environment, 0); //----------------------Assert----------------------- var actualInnerActivity = sut.ActivityFunc.Handler; Assert.AreEqual("Assign", actualInnerActivity.DisplayName); Assert.IsTrue(debugInputs is List <DebugItem>, "Debug inputs must return List<DebugItem>"); Assert.AreEqual(5, debugInputs.Count); Assert.AreEqual(1, debugInputs[0].ResultsList.Count); AssertDebugItems(debugInputs, 0, 0, "Key", null, "=", sut.Key); AssertDebugItems(debugInputs, 1, 0, "Redis key { " + sut.Key + " } not found", null, "", ""); AssertDebugItems(debugInputs, 2, 0, "1", null, "", ""); AssertDebugItems(debugInputs, 2, 1, null, "[[objectId1]]", "=", "ObjectName1"); AssertDebugItems(debugInputs, 3, 0, "2", null, "", ""); AssertDebugItems(debugInputs, 3, 1, null, "[[objectId2]]", "=", "ObjectName2"); AssertDebugItems(debugInputs, 4, 0, "3", null, "", ""); AssertDebugItems(debugInputs, 4, 1, null, isCalValue, "=", isCalValue); }
public void SequenceDesignerViewModel_SetSmallViewItem_WhenValidModelItem_ActivityAdded() { //------------Setup for test-------------------------- var dsfSequenceActivity = new DsfSequenceActivity(); var dsfMultiAssignActivity = new DsfMultiAssignActivity(); dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity); var dsfFindRecordsMultipleCriteriaActivity = new DsfFindRecordsMultipleCriteriaActivity(); dsfSequenceActivity.Activities.Add(dsfFindRecordsMultipleCriteriaActivity); var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity)); ModelItem modelItem = ModelItemUtils.CreateModelItem(new DsfGatherSystemInformationActivity()); //------------Execute Test--------------------------- sequenceDesignerViewModel.SmallViewItem = modelItem; //------------Assert Results------------------------- Assert.AreEqual(3, dsfSequenceActivity.Activities.Count); }
public void SequenceDesignerViewModel_SetSmallViewItem_WhenModelItemDsfDbServiceActivity_ActivityNotAdded() { //------------Setup for test-------------------------- var dsfSequenceActivity = new DsfSequenceActivity(); var dsfMultiAssignActivity = new DsfMultiAssignActivity(); dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity); var dsfFindRecordsMultipleCriteriaActivity = new DsfFindRecordsMultipleCriteriaActivity(); dsfSequenceActivity.Activities.Add(dsfFindRecordsMultipleCriteriaActivity); var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity)); ModelItem modelItem = ModelItemUtils.CreateModelItem(new DsfDatabaseActivity()); //------------Execute Test--------------------------- sequenceDesignerViewModel.SmallViewItem = modelItem; //------------Assert Results------------------------- Assert.AreEqual(2, dsfSequenceActivity.Activities.Count); }
public void SequenceActivityFindMissingStrategy_GetActivityFields_WithAssignAndDecision_ReturnsAllVariables() { //------------Setup for test-------------------------- DsfMultiAssignActivity multiAssignActivity = new DsfMultiAssignActivity { FieldsCollection = new List<ActivityDTO> { new ActivityDTO("[[AssignRight1]]", "[[AssignLeft1]]", 1), new ActivityDTO("[[AssignRight2]]", "[[AssignLeft2]]", 2) } }; DsfFlowDecisionActivity decisionActivity = new DsfFlowDecisionActivity { OnErrorVariable = "[[error]]" }; DsfSequenceActivity activity = new DsfSequenceActivity(); activity.Activities.Add(multiAssignActivity); activity.Activities.Add(decisionActivity); Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory(); IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.Sequence); //------------Execute Test--------------------------- List<string> actual = strategy.GetActivityFields(activity); //------------Assert Results------------------------- List<string> expected = new List<string> { "[[AssignRight1]]", "[[AssignLeft1]]", "[[AssignRight2]]", "[[AssignLeft2]]", "[[error]]" }; CollectionAssert.AreEqual(expected, actual); }
protected override void BuildDataList() { BuildShapeAndTestData(); List<ActivityDTO> fieldCollection; ScenarioContext.Current.TryGetValue("fieldCollection", out fieldCollection); var multiAssign = new DsfMultiAssignActivity(); TestStartNode = new FlowStep { Action = multiAssign }; foreach(var field in fieldCollection) { multiAssign.FieldsCollection.Add(field); } ScenarioContext.Current.Add("activity", multiAssign); }
public void SequenceActivityFindMissingStrategy_GetActivityFields_WithAssignAndDataMerge_ReturnsAllVariables() { //------------Setup for test-------------------------- DsfMultiAssignActivity multiAssignActivity = new DsfMultiAssignActivity { FieldsCollection = new List<ActivityDTO> { new ActivityDTO("[[AssignRight1]]", "[[AssignLeft1]]", 1), new ActivityDTO("[[AssignRight2]]", "[[AssignLeft2]]", 2) } }; DsfDataMergeActivity dataMergeActivity = new DsfDataMergeActivity { Result = "[[Result]]" }; dataMergeActivity.MergeCollection.Add(new DataMergeDTO("[[rec().a]]", "Index", "6", 1, "[[b]]", "Left")); DsfActivity dsfActivity = new DsfActivity { InputMapping = @"<Inputs><Input Name=""reg"" Source=""NUD2347"" DefaultValue=""NUD2347""><Validator Type=""Required"" /></Input><Input Name=""asdfsad"" Source=""registration223"" DefaultValue=""w3rt24324""><Validator Type=""Required"" /></Input><Input Name=""number"" Source=""[[number]]"" /></Inputs>", OutputMapping = @"<Outputs><Output Name=""vehicleVin"" MapsTo=""VIN"" Value="""" /><Output Name=""vehicleColor"" MapsTo=""VehicleColor"" Value="""" /><Output Name=""speed"" MapsTo=""speed"" Value="""" Recordset=""Fines"" /><Output Name=""date"" MapsTo=""date"" Value=""Fines.Date"" Recordset=""Fines"" /><Output Name=""location"" MapsTo=""location"" Value="""" Recordset=""Fines"" /></Outputs>" }; DsfForEachActivity forEachActivity = new DsfForEachActivity { ForEachElementName = "5", DataFunc = { Handler = dsfActivity } }; DsfSequenceActivity activity = new DsfSequenceActivity(); activity.Activities.Add(multiAssignActivity); activity.Activities.Add(dataMergeActivity); activity.Activities.Add(forEachActivity); Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory(); IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.Sequence); //------------Execute Test--------------------------- List<string> actual = strategy.GetActivityFields(activity); //------------Assert Results------------------------- List<string> expected = new List<string> { "[[AssignRight1]]", "[[AssignLeft1]]", "[[AssignRight2]]", "[[AssignLeft2]]", "[[b]]", "[[rec().a]]", "6", "[[Result]]", "NUD2347", "registration223", "[[number]]", "Fines.Date", "5" }; CollectionAssert.AreEqual(expected, actual); }
public void ForEachDesignerViewModel_MultipleItems_ModelItemsFormatListOfModelItemActivities_AddedToSequence() { //------------Setup for test-------------------------- var modelItem = CreateModelItem(); var viewModel = new ForeachDesignerViewModel(modelItem); var assignActivity = new DsfMultiAssignActivity(); var gatherSystemInformationActivity = new DsfGatherSystemInformationActivity(); var numberFormatActivity = new DsfNumberFormatActivity(); var dataObject = new DataObject("ModelItemsFormat", new List<ModelItem> { ModelItemUtils.CreateModelItem(gatherSystemInformationActivity), ModelItemUtils.CreateModelItem(assignActivity), ModelItemUtils.CreateModelItem(numberFormatActivity) }); //------------Execute Test--------------------------- bool multipleItemsToSequence = viewModel.MultipleItemsToSequence(dataObject); //------------Assert Results------------------------- Assert.IsTrue(multipleItemsToSequence); // var dsfSequenceActivity = multipleItemsToSequence.GetCurrentValue() as DsfSequenceActivity; // Assert.IsNotNull(dsfSequenceActivity); // Assert.AreEqual(3, dsfSequenceActivity.Activities.Count); // Assert.AreEqual(gatherSystemInformationActivity, dsfSequenceActivity.Activities[0]); // Assert.AreEqual(assignActivity, dsfSequenceActivity.Activities[1]); // Assert.AreEqual(numberFormatActivity, dsfSequenceActivity.Activities[2]); }
public void SequenceDesignerViewModel_SetModelItemForServiceTypes_DataHaveDataContextResourceModel_NothingAddedToDataObject() { //------------Setup for test-------------------------- var dsfSequenceActivity = new DsfSequenceActivity(); var dsfMultiAssignActivity = new DsfMultiAssignActivity(); dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity); SetupEnvironmentRepo(Guid.Empty); var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity)); var dataObject = new DataObject(GlobalConstants.ExplorerItemModelFormat, new ExplorerItemModel { DisplayName = "MyDBService", ResourceType = ResourceType.DbService, EnvironmentId = Guid.Empty }); //------------Execute Test--------------------------- bool added = sequenceDesignerViewModel.SetModelItemForServiceTypes(dataObject); //------------Assert Results------------------------- Assert.IsTrue(added); Assert.AreEqual(2, dsfSequenceActivity.Activities.Count); }
public void DsfMultiAssignActivity_GetForEachOutputs_Normal_UpdateSuccessful() { //------------Setup for test-------------------------- List<ActivityDTO> fieldsCollection = new List<ActivityDTO> { new ActivityDTO("[[rs(*).val]]", "[[result]]", 1), }; DsfMultiAssignActivity act = new DsfMultiAssignActivity { FieldsCollection = fieldsCollection }; //------------Execute Test--------------------------- var inputs = act.GetForEachOutputs(); //------------Assert Results------------------------- Assert.AreEqual("[[rs(*).val]]", inputs[0].Value); Assert.AreEqual("[[result]]", inputs[0].Name); }
public void SequenceDesignerViewModel_DoDrop_WhenNoFormats_ActivityNotAdded() { //------------Setup for test-------------------------- var dsfSequenceActivity = new DsfSequenceActivity(); var dsfMultiAssignActivity = new DsfMultiAssignActivity(); dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity); var dsfFindRecordsMultipleCriteriaActivity = new DsfFindRecordsMultipleCriteriaActivity(); dsfSequenceActivity.Activities.Add(dsfFindRecordsMultipleCriteriaActivity); var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity)); var dataObjectMock = new Mock<IDataObject>(); dataObjectMock.Setup(o => o.GetFormats()).Returns(new string[] { }); //------------Execute Test--------------------------- bool doDrop = sequenceDesignerViewModel.DoDrop(dataObjectMock.Object); //------------Assert Results------------------------- Assert.IsFalse(doDrop); Assert.AreEqual(2, dsfSequenceActivity.Activities.Count); }
public void SequenceDesignerViewModel_DoDrop_WhenFormatDoesNotContainModelItemFormat_ActivityNotAdded() { //------------Setup for test-------------------------- var dsfSequenceActivity = new DsfSequenceActivity(); var dsfMultiAssignActivity = new DsfMultiAssignActivity(); dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity); var dsfFindRecordsMultipleCriteriaActivity = new DsfFindRecordsMultipleCriteriaActivity(); dsfSequenceActivity.Activities.Add(dsfFindRecordsMultipleCriteriaActivity); var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity)); var dataObjectMock = new Mock<IDataObject>(); dataObjectMock.Setup(o => o.GetFormats()).Returns(new[] { "Something Else" }); dataObjectMock.Setup(o => o.GetData("Something Else")).Returns(ModelItemUtils.CreateModelItem(new DsfGatherSystemInformationActivity())); //------------Execute Test--------------------------- bool doDrop = sequenceDesignerViewModel.DoDrop(dataObjectMock.Object); //------------Assert Results------------------------- Assert.IsFalse(doDrop); Assert.AreEqual(2, dsfSequenceActivity.Activities.Count); }
public void SequenceDesignerViewModel_DoDrop_WhenModelItemsFormatHasSingleItem_ActivitiesAdded() { //------------Setup for test-------------------------- var dsfSequenceActivity = new DsfSequenceActivity(); var dsfMultiAssignActivity = new DsfMultiAssignActivity(); dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity); var dsfFindRecordsMultipleCriteriaActivity = new DsfFindRecordsMultipleCriteriaActivity(); dsfSequenceActivity.Activities.Add(dsfFindRecordsMultipleCriteriaActivity); var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity)); var dataObjectMock = new Mock<IDataObject>(); dataObjectMock.Setup(o => o.GetFormats()).Returns(new[] { "ModelItemsFormat" }); dataObjectMock.Setup(o => o.GetData("ModelItemsFormat")).Returns(new List<ModelItem> { ModelItemUtils.CreateModelItem(new DsfGatherSystemInformationActivity()) }); //------------Execute Test--------------------------- bool doDrop = sequenceDesignerViewModel.DoDrop(dataObjectMock.Object); //------------Assert Results------------------------- Assert.IsTrue(doDrop); Assert.AreEqual(3, dsfSequenceActivity.Activities.Count); }
public void ForEachDesignerViewModel_MultipleItems_ModelItemsFormatListOfModelItemContainsOneActivity_NotAddedToSequence() { //------------Setup for test-------------------------- var modelItem = CreateModelItem(); var viewModel = new ForeachDesignerViewModel(modelItem); var assignActivity = new DsfMultiAssignActivity(); var dataObject = new DataObject("ModelItemsFormat", new List<ModelItem> { ModelItemUtils.CreateModelItem(assignActivity) }); //------------Execute Test--------------------------- bool multipleItemsToSequence = viewModel.MultipleItemsToSequence(dataObject); //------------Assert Results------------------------- Assert.IsFalse(multipleItemsToSequence); }
public void DsfMultiAssignActivity_UpdateForEachInputs_WhenContainsMatchingStar_UpdateSuccessful() { //------------Setup for test-------------------------- List<ActivityDTO> fieldsCollection = new List<ActivityDTO> { new ActivityDTO("[[result]]", "[[rs(*).val]]", 1), }; DsfMultiAssignActivity act = new DsfMultiAssignActivity { FieldsCollection = fieldsCollection }; //------------Execute Test--------------------------- act.UpdateForEachInputs(new List<Tuple<string, string>> { new Tuple<string, string>("[[rs(*).val]]", "[[rs(1).val]]"), }); //------------Assert Results------------------------- var collection = act.FieldsCollection; Assert.AreEqual("[[rs(1).val]]", collection[0].FieldValue); }
public void SequenceDesignerViewModel_ActivityNames_WhenMoreThan4_Has4NamesLastItemEllipsis() { //------------Setup for test-------------------------- var dsfSequenceActivity = new DsfSequenceActivity(); var dsfMultiAssignActivity = new DsfMultiAssignActivity(); dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity); var dsfFindRecordsMultipleCriteriaActivity = new DsfFindRecordsMultipleCriteriaActivity(); dsfSequenceActivity.Activities.Add(dsfFindRecordsMultipleCriteriaActivity); var dsfGatherSystemInformationActivity = new DsfGatherSystemInformationActivity(); dsfSequenceActivity.Activities.Add(dsfGatherSystemInformationActivity); var dsfBaseConvertActivity = new DsfBaseConvertActivity(); dsfSequenceActivity.Activities.Add(dsfBaseConvertActivity); var dsfCaseConvertActivity = new DsfCaseConvertActivity(); dsfSequenceActivity.Activities.Add(dsfCaseConvertActivity); var dsfCalculateActivity = new DsfCalculateActivity(); dsfSequenceActivity.Activities.Add(dsfCalculateActivity); var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity)); //------------Execute Test--------------------------- var activityNames = sequenceDesignerViewModel.ActivityNames; //------------Assert Results------------------------- Assert.AreEqual(5, activityNames.Count); Assert.AreEqual(dsfMultiAssignActivity.DisplayName, activityNames[0]); Assert.AreEqual(dsfFindRecordsMultipleCriteriaActivity.DisplayName, activityNames[1]); Assert.AreEqual(dsfGatherSystemInformationActivity.DisplayName, activityNames[2]); Assert.AreEqual(dsfBaseConvertActivity.DisplayName, activityNames[3]); Assert.AreEqual("...", activityNames[4]); CollectionAssert.DoesNotContain(activityNames, dsfCaseConvertActivity.DisplayName); CollectionAssert.DoesNotContain(activityNames, dsfCalculateActivity.DisplayName); }