예제 #1
0
        public void SelectAndApplyActivity_SetupExecute_GivenNumberFormatTool_ToCorrectFormat()
        {
            var activity = new DsfNumberFormatActivity
            {
                Expression            = "[[result]]",
                Result                = "[[result]]",
                RoundingType          = Dev2EnumConverter.ConvertEnumValueToString(enRoundingType.Up),
                RoundingDecimalPlaces = "2",
                DecimalPlacesToShow   = "2"
            };


            //------------Setup for test--------------------------
            SetupArgumentsForFormatNumber("", "", activity);
            //------------Execute Test---------------------------
            ExecuteProcess(DataObject);
            //------------Assert Results-------------------------
            var ages = DataObject.Environment.EvalAsListOfStrings("[[Person(*).Age]]", 0);

            Assert.AreEqual("5.27", ages[0]);
            Assert.AreEqual("2.30", ages[1]);
            Assert.AreEqual("1.00", ages[2]);
            Assert.AreEqual("-3.46", ages[3]);
            Assert.AreEqual("0.88", ages[4]);
        }
 public RandomDesignerViewModel(ModelItem modelItem)
     : base(modelItem)
 {
     AddTitleBarHelpToggle();
     RandomTypes        = Dev2EnumConverter.ConvertEnumsTypeToStringList <enRandomType>();
     SelectedRandomType = Dev2EnumConverter.ConvertEnumValueToString(RandomType);
 }
예제 #3
0
 public ForeachDesignerViewModel(ModelItem modelItem)
     : base(modelItem)
 {
     AddTitleBarHelpToggle();
     ForeachTypes        = Dev2EnumConverter.ConvertEnumsTypeToStringList <enForEachType>();
     SelectedForeachType = Dev2EnumConverter.ConvertEnumValueToString(ForEachType);
 }
예제 #4
0
 public ScriptDesignerViewModel(ModelItem modelItem)
     : base(modelItem)
 {
     AddTitleBarHelpToggle();
     ScriptTypes        = Dev2EnumConverter.ConvertEnumsTypeToStringList <enScriptType>();
     SelectedScriptType = Dev2EnumConverter.ConvertEnumValueToString(ScriptType);
 }
예제 #5
0
 public RandomDesignerViewModel(ModelItem modelItem)
     : base(modelItem)
 {
     RandomTypes        = Dev2EnumConverter.ConvertEnumsTypeToStringList <enRandomType>();
     SelectedRandomType = Dev2EnumConverter.ConvertEnumValueToString(RandomType);
     AddTitleBarLargeToggle();
     HelpText = Warewolf.Studio.Resources.Languages.HelpText.Tool_Utility_Random;
 }
 public ForeachDesignerViewModel(ModelItem modelItem)
     : base(modelItem)
 {
     ForeachTypes        = Dev2EnumConverter.ConvertEnumsTypeToStringList <enForEachType>();
     SelectedForeachType = Dev2EnumConverter.ConvertEnumValueToString(ForEachType);
     AddTitleBarLargeToggle();
     HelpText = Warewolf.Studio.Resources.Languages.HelpText.Tool_LoopConstruct_For_Each;
 }
예제 #7
0
 public FormatNumberTO(string number, enRoundingType roundingType, int roundingDecimalPlaces,
                       bool adjustDecimalPlaces, int decimalPlacesToShow)
 {
     Number                = "'" + number + "'";
     RoundingType          = Dev2EnumConverter.ConvertEnumValueToString(roundingType);
     RoundingDecimalPlaces = roundingDecimalPlaces;
     AdjustDecimalPlaces   = adjustDecimalPlaces;
     DecimalPlacesToShow   = decimalPlacesToShow;
 }
예제 #8
0
        public ScriptDesignerViewModel(ModelItem modelItem)
            : base(modelItem)
        {
            _eventPublisher = EventPublishers.Aggregator;
            _eventPublisher.Subscribe(this);

            EscapeScript              = true;
            ScriptTypes               = Dev2EnumConverter.ConvertEnumsTypeToStringList <enScriptType>();
            SelectedScriptType        = Dev2EnumConverter.ConvertEnumValueToString(ScriptType);
            ChooseScriptSourceCommand = new DelegateCommand(o => ChooseScriptSources());
            AddTitleBarLargeToggle();
            HelpText = Warewolf.Studio.Resources.Languages.HelpText.Tool_Scripting_Script;
        }
예제 #9
0
        public void SelectAndApplyActivity_SetupExecute_GivenNumberFormatTool_ToCorrectFormat_ComplexObjects()
        {
            var activity = new DsfNumberFormatActivity
            {
                Expression            = "[[result]]",
                Result                = "[[result]]",
                RoundingType          = Dev2EnumConverter.ConvertEnumValueToString(enRoundingType.Up),
                RoundingDecimalPlaces = "2",
                DecimalPlacesToShow   = "2"
            };


            //------------Setup for test--------------------------
            //SetupArgumentsForFormatNumber("", "", activity);
            DataObject.Environment = new ExecutionEnvironment();
            DataObject.Environment.AssignJson(new AssignValue("[[@Person().Age]]", "5.2687454"), 0);
            DataObject.Environment.AssignJson(new AssignValue("[[@Person().Age]]", "2.3"), 0);
            DataObject.Environment.AssignJson(new AssignValue("[[@Person().Age]]", "1"), 0);
            DataObject.Environment.AssignJson(new AssignValue("[[@Person().Age]]", "-3.4554"), 0);
            DataObject.Environment.AssignJson(new AssignValue("[[@Person().Age]]", "0.875768"), 0);
            const string dataSource = "[[@Person(*).Age]]";
            const string alias      = "[[result]]";
            DsfSelectAndApplyActivity dsfSelectAndApplyActivity = new DsfSelectAndApplyActivity
            {
                DataSource = dataSource,
                Alias      = alias,
                //ApplyActivity = activity
            };

            dsfSelectAndApplyActivity.ApplyActivityFunc.Handler = activity;
            TestStartNode = new FlowStep
            {
                Action = dsfSelectAndApplyActivity
            };
            CurrentDl = string.Empty;
            TestData  = string.Empty;
            //------------Execute Test---------------------------
            ExecuteProcess(DataObject);
            //------------Assert Results-------------------------
            var ages = DataObject.Environment.EvalAsListOfStrings("[[@Person(*).Age]]", 0);

            Assert.AreEqual("5.27", ages[0]);
            Assert.AreEqual("2.30", ages[1]);
            Assert.AreEqual("1.00", ages[2]);
            Assert.AreEqual("-3.46", ages[3]);
            Assert.AreEqual("0.88", ages[4]);
        }
예제 #10
0
        public ForeachDesignerViewModel(ModelItem modelItem)
            : base(modelItem)
        {
            ForeachTypes        = Dev2EnumConverter.ConvertEnumsTypeToStringList <enForEachType>();
            SelectedForeachType = Dev2EnumConverter.ConvertEnumValueToString(ForEachType);
            AddTitleBarLargeToggle();
            HelpText = Warewolf.Studio.Resources.Languages.HelpText.Tool_LoopConstruct_For_Each;
            var dataFunc = modelItem.Properties["DataFunc"]?.ComputedValue as ActivityFunc <string, bool>;

            DataFuncDisplayName = dataFunc?.Handler == null ? "" : dataFunc?.Handler?.DisplayName;
            var type = dataFunc?.Handler?.GetType();

            if (type != null)
            {
                DataFuncIcon = ModelItemUtils.GetImageSourceForToolFromType(type);
            }
        }
예제 #11
0
        //SetupArguments(ActivityStrings.NumberFormatActivity_DataList_WithData, ActivityStrings.NumberFormatActivity_DataList_Shape,
        //                  "[[resRecordSet().number]]", "[[recordSet(*).number]]", enRoundingType.Normal, "", "");
        private void SetupArguments(string currentDl, string testData, string result, string expression,
                                    enRoundingType roundingType, string roundingDecimalPlaces, string decimalPlacesToShow)
        {
            TestStartNode = new FlowStep
            {
                Action = new DsfNumberFormatActivity
                {
                    Expression            = expression,
                    Result                = result,
                    RoundingType          = Dev2EnumConverter.ConvertEnumValueToString(roundingType),
                    RoundingDecimalPlaces = roundingDecimalPlaces,
                    DecimalPlacesToShow   = decimalPlacesToShow,
                }
            };

            CurrentDl = testData;
            TestData  = currentDl;
        }
예제 #12
0
        public void SelectAndApplyActivity_SetupExecute_GivenNumberFormatTool_ToDifferentResult()
        {
            var activity = new DsfNumberFormatActivity
            {
                Expression            = "[[result]]",
                Result                = "[[b]]",
                RoundingType          = Dev2EnumConverter.ConvertEnumValueToString(enRoundingType.Up),
                RoundingDecimalPlaces = "2",
                DecimalPlacesToShow   = "2"
            };


            //------------Setup for test--------------------------
            SetupArgumentsForFormatNumber("", "", activity);
            //------------Execute Test---------------------------
            ExecuteProcess(DataObject);
            //------------Assert Results-------------------------
            var ages       = DataObject.Environment.EvalAsListOfStrings("[[Person(*).Age]]", 0);
            var evalAsList = DataObject.Environment.EvalAsList("[[b]]", 1);
        }
예제 #13
0
        public void SelectAndApplyActivity_SetupExecute_GivenNullDataSource_DataObjectsHasCorrectErrors()
        {
            var activity = new DsfNumberFormatActivity
            {
                Expression            = "[[result]]",
                Result                = "[[result]]",
                RoundingType          = Dev2EnumConverter.ConvertEnumValueToString(enRoundingType.Up),
                RoundingDecimalPlaces = "2",
                DecimalPlacesToShow   = "2"
            };


            //------------Setup for test--------------------------
            //SetupArgumentsForFormatNumber("", "", activity);
            DataObject.Environment = new ExecutionEnvironment();
            DataObject.Environment.AssignJson(new AssignValue("[[@Person().Age]]", "5.2687454"), 0);
            DataObject.Environment.AssignJson(new AssignValue("[[@Person().Age]]", "2.3"), 0);
            DataObject.Environment.AssignJson(new AssignValue("[[@Person().Age]]", "1"), 0);
            DataObject.Environment.AssignJson(new AssignValue("[[@Person().Age]]", "-3.4554"), 0);
            DataObject.Environment.AssignJson(new AssignValue("[[@Person().Age]]", "0.875768"), 0);
            DsfSelectAndApplyActivity dsfSelectAndApplyActivity = new DsfSelectAndApplyActivity();

            dsfSelectAndApplyActivity.ApplyActivityFunc.Handler = activity;
            TestStartNode = new FlowStep
            {
                Action = dsfSelectAndApplyActivity
            };
            CurrentDl = string.Empty;
            TestData  = string.Empty;
            //------------Execute Test---------------------------
            ExecuteProcess(DataObject);
            //------------Assert Results-------------------------
            var errors = DataObject.Environment.Errors;

            Assert.AreEqual(2, errors.Count);
            Assert.IsTrue(errors.Contains(ErrorResource.DataSourceEmpty));
            Assert.IsTrue(errors.Contains(string.Format(ErrorResource.CanNotBeEmpty, "Alias")));
        }
예제 #14
0
 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(Dev2EnumConverter.ConvertEnumValueToString(value as Enum));
 }