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();

            enRandomType randomType;
            ScenarioContext.Current.TryGetValue("randomType", out randomType);
            string length;
            ScenarioContext.Current.TryGetValue("length", out length);
            string rangeFrom;
            ScenarioContext.Current.TryGetValue("rangeFrom", out rangeFrom);
            string rangeTo;
            ScenarioContext.Current.TryGetValue("rangeTo", out rangeTo);

            var dsfRandom = new DsfRandomActivity
                {
                    RandomType = randomType,
                    Result = ResultVariable
                };

            if (!string.IsNullOrEmpty(length))
            {
                dsfRandom.Length = length;
            }

            if (!string.IsNullOrEmpty(rangeFrom))
            {
                dsfRandom.From = rangeFrom;
            }

            if (!string.IsNullOrEmpty(rangeTo))
            {
                dsfRandom.To = rangeTo;
            }

            TestStartNode = new FlowStep
                {
                    Action = dsfRandom
                };

            ScenarioContext.Current.Add("activity", dsfRandom);
        }
        public void DsfRandomActivity_GetForEachOutputs_WhenHasResult_ReturnsOutputList()
        {
            //------------Setup for test--------------------------
            const string From = "[[Numeric(1).num]]";
            const string To = "Up";
            const string Result = "[[res]]";
            const string Length = "2";
            var act = new DsfRandomActivity { From = From, To = To, Length = Length, Result = Result };

            //------------Execute Test---------------------------
            var dsfForEachItems = act.GetForEachOutputs();
            //------------Assert Results-------------------------
            Assert.AreEqual(1, dsfForEachItems.Count);
            Assert.AreEqual(Result, dsfForEachItems[0].Name);
            Assert.AreEqual(Result, dsfForEachItems[0].Value);
        }
        public void DsfRandomActivity_UpdateForEachOutputs_1Updates_UpdateCommandResult()
        {
            //------------Setup for test--------------------------
            const string From = "[[Numeric(1).num]]";
            const string To = "Up";
            const string Result = "[[res]]";
            const string Length = "2";
            var act = new DsfRandomActivity { From = From, To = To, Length = Length, Result = Result };

            var tuple1 = new Tuple<string, string>("[[res]]", "Test");
            //------------Execute Test---------------------------
            act.UpdateForEachOutputs(new List<Tuple<string, string>> { tuple1 });
            //------------Assert Results-------------------------
            Assert.AreEqual("Test", act.Result);
        }
        public void DsfRandomActivity_UpdateForEachOutputs_NullUpdates_DoesNothing()
        {
            //------------Setup for test--------------------------
            const string From = "[[Numeric(1).num]]";
            const string To = "Up";
            const string Result = "[[res]]";
            const string Length = "2";
            var act = new DsfRandomActivity { From = From, To = To, Length = Length, Result = Result };

            act.UpdateForEachOutputs(null);
            //------------Assert Results-------------------------
            Assert.AreEqual(Result, act.Result);
        }
        public void DsfRandomActivity_UpdateForEachInputs_MoreThan1Updates_Updates()
        {
            //------------Setup for test--------------------------
            const string From = "[[Numeric(1).num]]";
            const string To = "Up";
            const string Result = "[[res]]";
            const string Length = "2";
            var act = new DsfRandomActivity { From = From, To = To, Length = Length, Result = Result };

            var tuple1 = new Tuple<string, string>(From, "Test");
            var tuple2 = new Tuple<string, string>(To, "Test2");
            var tuple3 = new Tuple<string, string>(Length, "Test3");
            //------------Execute Test---------------------------
            act.UpdateForEachInputs(new List<Tuple<string, string>> { tuple1, tuple2, tuple3 });
            //------------Assert Results-------------------------
            Assert.AreEqual("Test2", act.To);
            Assert.AreEqual("Test", act.From);
            Assert.AreEqual("Test3", act.Length);
        }
Ejemplo n.º 6
0
        public void GivenItContainsRandomAs(string parentName, string activityName, Table table)
        {
            var activity = new DsfRandomActivity { DisplayName = activityName };
            foreach(var tableRow in table.Rows)
            {
                var type = (enRandomType)Enum.Parse(typeof(enRandomType), tableRow["Type"]);
                var from = tableRow["From"];
                var to = tableRow["To"];
                var result = tableRow["Result"];

                CommonSteps.AddVariableToVariableList(result);

                activity.RandomType = type;
                activity.To = to;
                activity.From = from;
                activity.Result = result;

            }

            CommonSteps.AddActivityToActivityList(parentName, activityName, activity);
        }