Ejemplo n.º 1
0
        protected override void BuildDataList()
        {
            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);
            }

            variableList.Add(new Tuple <string, string>(ResultVariable, ""));
            BuildShapeAndTestData();

            string recordSetName;

            ScenarioContext.Current.TryGetValue("recordset", out recordSetName);

            var recordset = ScenarioContext.Current.Get <string>("recordset");

            var length = new DsfRecordsetLengthActivity
            {
                RecordsetName = recordset,
                RecordsLength = ResultVariable
            };

            TestStartNode = new FlowStep
            {
                Action = length
            };
            ScenarioContext.Current.Add("activity", length);
        }
Ejemplo n.º 2
0
        //protected override void BuildDataList()
        //{
        //    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);
        //    }

        //    variableList.Add(new Tuple<string, string>(ResultVariable, ""));
        //    BuildShapeAndTestData();


        //}

        protected override void BuildDataList()
        {
            var shape = new XElement("root");
            var data  = new XElement("root");

            // ReSharper disable NotAccessedVariable
            int     row = 0;
            dynamic variableList;

            ScenarioContext.Current.TryGetValue("variableList", out variableList);

            if (variableList != null)
            {
                foreach (dynamic variable in variableList)
                {
                    if (!string.IsNullOrEmpty(variable.Item1) && !string.IsNullOrEmpty(variable.Item2))
                    {
                        string value = variable.Item2 == "blank" ? "" : variable.Item2;
                        if (value.ToUpper() == "NULL")
                        {
                            DataObject.Environment.AssignDataShape((variable.Item1));
                        }
                        else
                        {
                            DataObject.Environment.AssignWithFrame(new AssignValue(DataListUtil.AddBracketsToValueIfNotExist(variable.Item1), value), 0);
                        }
                    }
                    //Build(variable, shape, data, row);
                    row++;
                }
                DataObject.Environment.CommitAssign();
            }

            string recordSetName;

            ScenarioContext.Current.TryGetValue("recordset", out recordSetName);

            var recordset = ScenarioContext.Current.Get <string>("recordset");

            var length = new DsfRecordsetLengthActivity
            {
                RecordsetName = recordset,
                RecordsLength = ResultVariable
            };

            TestStartNode = new FlowStep
            {
                Action = length
            };
            ScenarioContext.Current.Add("activity", length);
            CurrentDl = shape.ToString();
            TestData  = data.ToString();
        }
Ejemplo n.º 3
0
        public void RecordsetLengthRecordsetActivity_GetInputs_Expected_One_Input()
        {
            DsfRecordsetLengthActivity testAct = new DsfRecordsetLengthActivity();

            IBinaryDataList inputs = testAct.GetInputs();

            var result = inputs.FetchAllEntries().Count;

            // remove test datalist ;)

            Assert.AreEqual(1, result);
        }
Ejemplo n.º 4
0
        public void DsfRecordsetLengthActivity_UpdateForEachInputs_NullUpdates_DoesNothing()
        {
            //------------Setup for test--------------------------
            const string recordsetName = "[[Customers()]]";
            var          act           = new DsfRecordsetLengthActivity {
                RecordsetName = recordsetName, RecordsLength = "[[res]]"
            };

            //------------Execute Test---------------------------
            act.UpdateForEachInputs(null);
            //------------Assert Results-------------------------
            Assert.AreEqual(recordsetName, act.RecordsetName);
        }
Ejemplo n.º 5
0
        public void DsfRecordsetLengthActivity_GetOutputs_Called_ShouldReturnListWithResultValueInIt()
        {
            //------------Setup for test--------------------------
            const string recordsetName = "[[Customers()]]";
            var          act           = new DsfRecordsetLengthActivity {
                RecordsetName = recordsetName, RecordsLength = "[[res]]"
            };
            //------------Execute Test---------------------------
            var outputs = act.GetOutputs();

            //------------Assert Results-------------------------
            Assert.AreEqual(1, outputs.Count);
            Assert.AreEqual("[[res]]", outputs[0]);
        }
        public void GetActivityFieldsOffDsfRecordsetLengthActivityExpectedAllFindMissingFieldsToBeReturned()
        {
            DsfRecordsetLengthActivity activity = new DsfRecordsetLengthActivity();

            activity.RecordsetName = "[[RecordsetName]]";
            activity.RecordsLength = "[[CountNumber]]";
            Dev2FindMissingStrategyFactory fac      = new Dev2FindMissingStrategyFactory();
            IFindMissingStrategy           strategy = fac.CreateFindMissingStrategy(enFindMissingType.StaticActivity);
            List <string> actual   = strategy.GetActivityFields(activity);
            List <string> expected = new List <string> {
                "[[RecordsetName]]", "[[CountNumber]]"
            };

            CollectionAssert.AreEqual(expected, actual);
        }
Ejemplo n.º 7
0
        public void DsfRecordsetLengthActivity_GetForEachOutputs_WhenHasResult_ReturnsInputList()
        {
            //------------Setup for test--------------------------
            const string recordsetName = "[[Customers()]]";
            var          act           = new DsfRecordsetLengthActivity {
                RecordsetName = recordsetName, RecordsLength = "[[res]]"
            };
            //------------Execute Test---------------------------
            var dsfForEachItems = act.GetForEachOutputs();

            //------------Assert Results-------------------------
            Assert.AreEqual(1, dsfForEachItems.Count);
            Assert.AreEqual("[[res]]", dsfForEachItems[0].Name);
            Assert.AreEqual("[[res]]", dsfForEachItems[0].Value);
        }
Ejemplo n.º 8
0
        public void DsfRecordsetLengthActivity_UpdateForEachOutputs_1Updates_UpdateRecordsLength()
        {
            //------------Setup for test--------------------------
            const string recordsetName = "[[Customers()]]";
            var          act           = new DsfRecordsetLengthActivity {
                RecordsetName = recordsetName, RecordsLength = "[[res]]"
            };
            var tuple1 = new Tuple <string, string>("Test", "Test");

            //------------Execute Test---------------------------
            act.UpdateForEachOutputs(new List <Tuple <string, string> > {
                tuple1
            });
            //------------Assert Results-------------------------
            Assert.AreEqual("Test", act.RecordsLength);
        }
Ejemplo n.º 9
0
        public void DsfRecordsetLengthActivity_UpdateForEachInputs_MoreThan1Updates_DoesNothing()
        {
            //------------Setup for test--------------------------
            const string recordsetName = "[[Customers()]]";
            var          act           = new DsfRecordsetLengthActivity {
                RecordsetName = recordsetName, RecordsLength = "[[res]]"
            };
            var tuple1 = new Tuple <string, string>("Test", "Test");
            var tuple2 = new Tuple <string, string>("Test2", "Test2");

            //------------Execute Test---------------------------
            act.UpdateForEachInputs(new List <Tuple <string, string> > {
                tuple1, tuple2
            });
            //------------Assert Results-------------------------
            Assert.AreEqual(recordsetName, act.RecordsetName);
        }
Ejemplo n.º 10
0
        public void DsfRecordsetLengthActivity_GetState_ReturnsStateVariable()
        {
            //---------------Set up test pack-------------------
            //------------Setup for test--------------------------
            var act = new DsfRecordsetLengthActivity {
                RecordsetName = "[[recset()]]", RecordsLength = "[[len]]"
            };
            //------------Execute Test---------------------------
            var stateItems = act.GetState();

            Assert.AreEqual(2, stateItems.Count());

            var expectedResults = new[]
            {
                new StateVariable
                {
                    Name  = "RecordsetName",
                    Type  = StateVariable.StateType.Input,
                    Value = "[[recset()]]"
                },
                new StateVariable
                {
                    Name  = "RecordsLength",
                    Type  = StateVariable.StateType.Output,
                    Value = "[[len]]"
                }
            };

            var iter = act.GetState().Select(
                (item, index) => new
            {
                value       = item,
                expectValue = expectedResults[index]
            }
                );

            //------------Assert Results-------------------------
            foreach (var entry in iter)
            {
                Assert.AreEqual(entry.expectValue.Name, entry.value.Name);
                Assert.AreEqual(entry.expectValue.Type, entry.value.Type);
                Assert.AreEqual(entry.expectValue.Value, entry.value.Value);
            }
        }
Ejemplo n.º 11
0
        //protected override void BuildDataList()
        //{
        //    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);
        //    }

        //    variableList.Add(new Tuple<string, string>(ResultVariable, ""));
        //    BuildShapeAndTestData();


        //}

        protected override void BuildDataList()
        {
            var shape = new XElement("root");
            var data = new XElement("root");

            // ReSharper disable NotAccessedVariable
            int row = 0;
            dynamic variableList;
            ScenarioContext.Current.TryGetValue("variableList", out variableList);

            if (variableList != null)
            {
                foreach (dynamic variable in variableList)
                {
                    if (!string.IsNullOrEmpty(variable.Item1) && !string.IsNullOrEmpty(variable.Item2))
                    {
                        DataObject.Environment.AssignWithFrame(new AssignValue(DataListUtil.AddBracketsToValueIfNotExist(variable.Item1), variable.Item2));
                    }
                    row++;
                }
                DataObject.Environment.CommitAssign();
            }

            string recordSetName;
            ScenarioContext.Current.TryGetValue("recordset", out recordSetName);

            var recordset = ScenarioContext.Current.Get<string>("recordset");

            var length = new DsfRecordsetLengthActivity
            {
                RecordsetName = recordset,
                RecordsLength = ResultVariable
            };

            TestStartNode = new FlowStep
            {
                Action = length
            };
            ScenarioContext.Current.Add("activity", length);
            CurrentDl = shape.ToString();
            TestData = data.ToString();
        }
 public void GetActivityFieldsOffDsfRecordsetLengthActivityExpectedAllFindMissingFieldsToBeReturned()
 {
     DsfRecordsetLengthActivity activity = new DsfRecordsetLengthActivity();
     activity.RecordsetName = "[[RecordsetName]]";
     activity.RecordsLength = "[[CountNumber]]";
     Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory();
     IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.StaticActivity);
     List<string> actual = strategy.GetActivityFields(activity);
     List<string> expected = new List<string> { "[[RecordsetName]]", "[[CountNumber]]" };
     CollectionAssert.AreEqual(expected, actual);
 }
Ejemplo n.º 13
0
 public void DsfRecordsetLengthActivity_UpdateForEachInputs_MoreThan1Updates_DoesNothing()
 {
     //------------Setup for test--------------------------
     const string recordsetName = "[[Customers()]]";
     var act = new DsfRecordsetLengthActivity { RecordsetName = recordsetName, RecordsLength = "[[res]]" };
     var tuple1 = new Tuple<string, string>("Test", "Test");
     var tuple2 = new Tuple<string, string>("Test2", "Test2");
     //------------Execute Test---------------------------
     act.UpdateForEachInputs(new List<Tuple<string, string>> { tuple1, tuple2 });
     //------------Assert Results-------------------------
     Assert.AreEqual(recordsetName, act.RecordsetName);
 }
        public void RecordsetLengthRecordsetActivity_GetInputs_Expected_One_Input()
        {
            DsfRecordsetLengthActivity testAct = new DsfRecordsetLengthActivity();

            IBinaryDataList inputs = testAct.GetInputs();

            var result = inputs.FetchAllEntries().Count;

            // remove test datalist ;)

            Assert.AreEqual(1, result);
        }
Ejemplo n.º 15
0
 public void DsfRecordsetLengthActivity_UpdateForEachOutputs_1Updates_UpdateRecordsLength()
 {
     //------------Setup for test--------------------------
     const string recordsetName = "[[Customers()]]";
     var act = new DsfRecordsetLengthActivity { RecordsetName = recordsetName, RecordsLength = "[[res]]" };
     var tuple1 = new Tuple<string, string>("Test", "Test");
     //------------Execute Test---------------------------
     act.UpdateForEachOutputs(new List<Tuple<string, string>> { tuple1 });
     //------------Assert Results-------------------------
     Assert.AreEqual("Test", act.RecordsLength);
 }
Ejemplo n.º 16
0
        protected override void BuildDataList()
        {
            var shape = new XElement("root");
            var data  = new XElement("root");

            var row = 0;

            scenarioContext.TryGetValue("variableList", out dynamic variableList);

            if (variableList != null)
            {
                foreach (dynamic variable in variableList)
                {
                    if (!string.IsNullOrEmpty(variable.Item1) && !string.IsNullOrEmpty(variable.Item2))
                    {
                        string value = variable.Item2 == "blank" ? "" : variable.Item2;
                        if (value.ToUpper() == "NULL")
                        {
                            DataObject.Environment.AssignDataShape(variable.Item1);
                        }
                        else
                        {
                            DataObject.Environment.AssignWithFrame(new AssignValue(DataListUtil.AddBracketsToValueIfNotExist(variable.Item1), value), 0);
                        }
                    }
                    row++;
                }
                DataObject.Environment.CommitAssign();
            }

            scenarioContext.TryGetValue("recordset", out string recordSetName);

            var recordset = scenarioContext.Get <string>("recordset");

            scenarioContext.TryGetValue("treaNullAsZero", out bool treaNullAsZero);

            //var length = new DsfRecordsetNullhandlerLengthActivity
            //{
            //    RecordsetName = recordset,
            //    RecordsLength = ResultVariable,
            //    TreatNullAsZero = treaNullAsZero
            //};
            scenarioContext.TryGetValue("activityMode", out DsfActivityAbstract <string> length);
            if (length != null)
            {
                length = new DsfRecordsetNullhandlerLengthActivity
                {
                    RecordsetName   = recordset,
                    RecordsLength   = ResultVariable,
                    TreatNullAsZero = treaNullAsZero
                };
            }
            else
            {
                length = new DsfRecordsetLengthActivity
                {
                    RecordsetName = recordset,
                    RecordsLength = ResultVariable,
                };
            }

            TestStartNode = new FlowStep
            {
                Action = length
            };
            scenarioContext.Add("activity", length);
            CurrentDl = shape.ToString();
            TestData  = data.ToString();
        }
Ejemplo n.º 17
0
 public void DsfRecordsetLengthActivity_UpdateForEachInputs_NullUpdates_DoesNothing()
 {
     //------------Setup for test--------------------------
     const string recordsetName = "[[Customers()]]";
     var act = new DsfRecordsetLengthActivity { RecordsetName = recordsetName, RecordsLength = "[[res]]" };
     //------------Execute Test---------------------------
     act.UpdateForEachInputs(null);
     //------------Assert Results-------------------------
     Assert.AreEqual(recordsetName, act.RecordsetName);
 }
Ejemplo n.º 18
0
 public void DsfRecordsetLengthActivity_GetForEachOutputs_WhenHasResult_ReturnsInputList()
 {
     //------------Setup for test--------------------------
     const string recordsetName = "[[Customers()]]";
     var act = new DsfRecordsetLengthActivity { RecordsetName = recordsetName, RecordsLength = "[[res]]" };
     //------------Execute Test---------------------------
     var dsfForEachItems = act.GetForEachOutputs();
     //------------Assert Results-------------------------
     Assert.AreEqual(1, dsfForEachItems.Count);
     Assert.AreEqual("[[res]]", dsfForEachItems[0].Name);
     Assert.AreEqual("[[res]]", dsfForEachItems[0].Value);
 }