예제 #1
0
        public void GivenItContainsDateAndTimeAs(string parentName, string activityName, Table table)
        {
            var activity = new DsfDateTimeActivity {
                DisplayName = activityName
            };

            foreach (var tableRow in table.Rows)
            {
                var input1             = tableRow["Input"];
                var outputFormat       = tableRow["Output Format"];
                var inputFormat        = tableRow["Input Format"];
                var timeModifierAmount = tableRow["Add Time"];
                var result             = tableRow["Result"];

                _commonSteps.AddVariableToVariableList(result);

                activity.DateTime     = input1;
                activity.InputFormat  = inputFormat;
                activity.OutputFormat = outputFormat;
                activity.TimeModifierAmountDisplay = timeModifierAmount;
                activity.TimeModifierType          = "Years";
                activity.Result = result;
            }

            _commonSteps.AddActivityToActivityList(parentName, activityName, activity);
        }
예제 #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();

            string inputDate;

            ScenarioContext.Current.TryGetValue("inputDate", out inputDate);
            string inputFormat;

            ScenarioContext.Current.TryGetValue("inputFormat", out inputFormat);
            string outputFormat;

            ScenarioContext.Current.TryGetValue("outputFormat", out outputFormat);
            string timeModifierType;

            ScenarioContext.Current.TryGetValue("timeModifierType", out timeModifierType);
            string timeModifierAmount;

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

            //Ashley: Windows Server 2008 is too outdated to know GMT was renamed to UTC.
            if (Environment.OSVersion.ToString() == "Microsoft Windows NT 6.0.6002 Service Pack 2")
            {
                inputDate = inputDate.Replace("(UTC+", "(GMT+").Replace("(UTC-", "(GMT-");
            }

            var dateTime = new DsfDateTimeActivity
            {
                Result                    = ResultVariable,
                DateTime                  = inputDate,
                InputFormat               = inputFormat,
                OutputFormat              = outputFormat,
                TimeModifierType          = timeModifierType,
                TimeModifierAmountDisplay = timeModifierAmount
            };

            TestStartNode = new FlowStep
            {
                Action = dateTime
            };

            ScenarioContext.Current.Add("activity", dateTime);
        }
        public void DateTimeActivity_GetOutputs_Expected_One_Output()
        {
            DsfDateTimeActivity testAct = new DsfDateTimeActivity {
                DateTime = "27-10-2012", InputFormat = "DD-mm-yyyy", TimeModifierType = "Days", TimeModifierAmount = 5, TimeModifierAmountDisplay = "5", OutputFormat = "DD-mm-yyyy", Result = "[[result]]"
            };

            IBinaryDataList outputs = testAct.GetOutputs();

            // remove test datalist ;)

            Assert.AreEqual(1, outputs.FetchAllEntries().Count);
        }
        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 inputDate;
            ScenarioContext.Current.TryGetValue("inputDate", out inputDate);
            string inputFormat;
            ScenarioContext.Current.TryGetValue("inputFormat", out inputFormat);
            string outputFormat;
            ScenarioContext.Current.TryGetValue("outputFormat", out outputFormat);
            string timeModifierType;
            ScenarioContext.Current.TryGetValue("timeModifierType", out timeModifierType);
            string timeModifierAmount;
            ScenarioContext.Current.TryGetValue("timeModifierAmount", out timeModifierAmount);

            //Ashley: Windows Server 2008 is too outdated to know GMT was renamed to UTC.
            if(Environment.OSVersion.ToString() == "Microsoft Windows NT 6.0.6002 Service Pack 2")
            {
                inputDate = inputDate.Replace("(UTC+", "(GMT+").Replace("(UTC-", "(GMT-");
            }

            var dateTime = new DsfDateTimeActivity
                {
                    Result = ResultVariable,
                    DateTime = inputDate,
                    InputFormat = inputFormat,
                    OutputFormat = outputFormat,
                    TimeModifierType = timeModifierType,
                    TimeModifierAmountDisplay = timeModifierAmount
                };

            TestStartNode = new FlowStep
                {
                    Action = dateTime
                };

            ScenarioContext.Current.Add("activity", dateTime);
        }
        public void DsfDateTimeActivity_GetOutputs_Called_ShouldReturnListWithResultValueInIt()
        {
            //------------Setup for test--------------------------
            var act = new DsfDateTimeActivity
            {
                DateTime                  = "", InputFormat = "", OutputFormat = "", TimeModifierType = "",
                TimeModifierAmount        = 1, Result = "[[dt]]",
                TimeModifierAmountDisplay = 1.ToString(CultureInfo.InvariantCulture)
            };
            //------------Execute Test---------------------------
            var outputs = act.GetOutputs();

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

            activity.DateTime     = "[[DateTime]]";
            activity.InputFormat  = "[[InputFormat]]";
            activity.OutputFormat = "[[OutputFormat]]";
            activity.TimeModifierAmountDisplay = "[[TimeModifierAmountDisplay]]";
            activity.Result = "[[Result]]";
            Dev2FindMissingStrategyFactory fac      = new Dev2FindMissingStrategyFactory();
            IFindMissingStrategy           strategy = fac.CreateFindMissingStrategy(enFindMissingType.StaticActivity);
            List <string> actual   = strategy.GetActivityFields(activity);
            List <string> expected = new List <string> {
                "[[DateTime]]", "[[InputFormat]]", "[[OutputFormat]]", "[[TimeModifierAmountDisplay]]", "[[Result]]"
            };

            CollectionAssert.AreEqual(expected, actual);
        }
        public void Dev2FindMissingStrategyFactory_GetActivityFieldsOff_DsfDateTime_Activity_ExpectAllFindMissingFieldsToBeReturned()
        {
            var activity = new DsfDateTimeActivity
            {
                DateTime     = "[[DateTime]]",
                InputFormat  = "[[InputFormat]]",
                OutputFormat = "[[OutputFormat]]",
                TimeModifierAmountDisplay = "[[TimeModifierAmountDisplay]]",
                Result = "[[Result]]"
            };
            var fac      = new Dev2FindMissingStrategyFactory();
            var strategy = fac.CreateFindMissingStrategy(enFindMissingType.StaticActivity);
            var actual   = strategy.GetActivityFields(activity);
            var expected = new List <string> {
                "[[DateTime]]", "[[InputFormat]]", "[[OutputFormat]]", "[[TimeModifierAmountDisplay]]", "[[Result]]"
            };

            CollectionAssert.AreEqual(expected, actual);
        }
        public void Equals_Given_DisplayName_Different_DisplayName_Is_Not_Equal()
        {
            //---------------Set up test pack-------------------
            var uniqueId  = Guid.NewGuid().ToString();
            var activity1 = new DsfDateTimeActivity()
            {
                UniqueID = uniqueId, DisplayName = "A"
            };
            var activity = new DsfDateTimeActivity()
            {
                UniqueID = uniqueId, DisplayName = "ass"
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(activity1);
            //---------------Execute Test ----------------------
            var @equals = activity1.Equals(activity);

            //---------------Test Result -----------------------
            Assert.IsFalse(@equals);
        }
        public void Equals_Given_Same_TimeModifierAmountDisplay_IsEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId  = Guid.NewGuid().ToString();
            var activity1 = new DsfDateTimeActivity()
            {
                UniqueID = uniqueId, TimeModifierAmountDisplay = "a"
            };
            var activity = new DsfDateTimeActivity()
            {
                UniqueID = uniqueId, TimeModifierAmountDisplay = "a"
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(activity1);
            //---------------Execute Test ----------------------
            var @equals = activity1.Equals(activity);

            //---------------Test Result -----------------------
            Assert.IsTrue(@equals);
        }
        public void Equals_Given_EmptyActivityTools_AreEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var activity = new DsfDateTimeActivity()
            {
                UniqueID = uniqueId
            };
            var activity1 = new DsfDateTimeActivity()
            {
                UniqueID = uniqueId
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(activity);
            //---------------Execute Test ----------------------
            var @equals = activity.Equals(activity1);

            //---------------Test Result -----------------------
            Assert.IsTrue(@equals);
        }
 public void GetActivityFieldsOffDsfDateTimeActivityExpectedAllFindMissingFieldsToBeReturned()
 {
     DsfDateTimeActivity activity = new DsfDateTimeActivity();
     activity.DateTime = "[[DateTime]]";
     activity.InputFormat = "[[InputFormat]]";
     activity.OutputFormat = "[[OutputFormat]]";
     activity.TimeModifierAmountDisplay = "[[TimeModifierAmountDisplay]]";
     activity.Result = "[[Result]]";
     Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory();
     IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.StaticActivity);
     List<string> actual = strategy.GetActivityFields(activity);
     List<string> expected = new List<string> { "[[DateTime]]", "[[InputFormat]]", "[[OutputFormat]]", "[[TimeModifierAmountDisplay]]", "[[Result]]" };
     CollectionAssert.AreEqual(expected, actual);
 }
        public void DsfDateTimeActivity_GetState_ReturnsStateVariable()
        {
            //------------Setup for test--------------------------
            var calculateActivity = new DsfDateTimeActivity
            {
                DateTime                  = "2018/07/20",
                InputFormat               = "yyyy/MM/dd",
                OutputFormat              = "yyyy/MM/dd",
                TimeModifierType          = "days",
                TimeModifierAmountDisplay = "days",
                TimeModifierAmount        = 1,
                Result = "TimeChanged"
            };
            //------------Execute Test---------------------------
            var stateItems = calculateActivity.GetState();

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

            var expectedResults = new[]
            {
                new StateVariable
                {
                    Name  = "DateTime",
                    Type  = StateVariable.StateType.Input,
                    Value = "2018/07/20"
                },
                new StateVariable
                {
                    Name  = "InputFormat",
                    Type  = StateVariable.StateType.Input,
                    Value = "yyyy/MM/dd"
                },
                new StateVariable
                {
                    Name  = "OutputFormat",
                    Type  = StateVariable.StateType.Input,
                    Value = "yyyy/MM/dd"
                },
                new StateVariable
                {
                    Name  = "TimeModifierType",
                    Type  = StateVariable.StateType.Input,
                    Value = "days"
                },
                new StateVariable
                {
                    Name  = "TimeModifierAmountDisplay",
                    Type  = StateVariable.StateType.Input,
                    Value = "days"
                },
                new StateVariable
                {
                    Name  = "TimeModifierAmount",
                    Type  = StateVariable.StateType.Input,
                    Value = "1"
                },
                new StateVariable
                {
                    Name  = "Result",
                    Type  = StateVariable.StateType.Output,
                    Value = "TimeChanged"
                }
            };

            var iter = calculateActivity.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);
            }
        }
예제 #13
0
        public void GivenItContainsDateAndTimeAs(string parentName, string activityName, Table table)
        {
            var activity = new DsfDateTimeActivity { DisplayName = activityName };
            foreach(var tableRow in table.Rows)
            {
                var input1 = tableRow["Input"];
                var outputFormat = tableRow["Output Format"];
                var inputFormat = tableRow["Input Format"];
                var timeModifierAmount = tableRow["Add Time"];
                var result = tableRow["Result"];

                CommonSteps.AddVariableToVariableList(result);

                activity.DateTime = input1;
                activity.InputFormat = inputFormat;
                activity.OutputFormat = outputFormat;
                activity.TimeModifierAmountDisplay = timeModifierAmount;
                activity.TimeModifierType = "Years";
                activity.Result = result;

            }

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