public virtual void BindData(ScreenObjectGeneratorOptions options)
 {
     ignoreLabels.DataBindings.Add("Checked", options, CodePath.Get(CodePath.New <ScreenObjectGeneratorOptions>().IgnoreLabels), false,
                                   DataSourceUpdateMode.OnPropertyChanged);
     namespaceText.DataBindings.Add("Text", options, CodePath.Get(CodePath.New <ScreenObjectGeneratorOptions>().Namespace), false,
                                    DataSourceUpdateMode.OnPropertyChanged);
 }
Beispiel #2
0
        /// <summary>
        /// Call VSCode with arguments
        /// </summary>
        static void CallVSCode(string args)
        {
            System.Diagnostics.Process proc = new System.Diagnostics.Process();
            if (!VSCodeExists(CodePath))
            {
                PrintNotFound(CodePath);
                return;
            }
#if UNITY_EDITOR_OSX
            proc.StartInfo.FileName = "open";
            // Check the path to see if there is "Insiders"
            if (CodePath.Contains("Insiders"))
            {
                proc.StartInfo.Arguments = " -n -b \"com.microsoft.VSCodeInsiders\" --args " + args.Replace(@"\", @"\\");
            }
            else
            {
                proc.StartInfo.Arguments = " -n -b \"com.microsoft.VSCode\" --args " + args.Replace(@"\", @"\\");
            }
            proc.StartInfo.UseShellExecute = false;
#elif UNITY_EDITOR_WIN
            proc.StartInfo.FileName        = CodePath;
            proc.StartInfo.Arguments       = args;
            proc.StartInfo.UseShellExecute = false;
#else
            proc.StartInfo.FileName        = CodePath;
            proc.StartInfo.Arguments       = args.Replace(@"\", @"\\");
            proc.StartInfo.UseShellExecute = false;
#endif
            proc.StartInfo.WindowStyle            = System.Diagnostics.ProcessWindowStyle.Hidden;
            proc.StartInfo.CreateNoWindow         = true;
            proc.StartInfo.RedirectStandardOutput = true;
            proc.Start();
        }
        public void ConcatNew_ConcatPartial_ShouldConcatFullChain(params string[][] parms)
        {
            // arrange
            var extraPath = new CodePath();
            var sut       = new CodePath();

            foreach (var name in parms[0])
            {
                var mockedMethod = Mock.Create <Method>();
                Mock.Arrange(() => mockedMethod.FullName).Returns(name);
                sut.AddLast(mockedMethod);
            }

            foreach (var name in parms[1])
            {
                var mockedMethod = Mock.Create <Method>();
                Mock.Arrange(() => mockedMethod.FullName).Returns(name);
                extraPath.AddLast(mockedMethod);
            }

            // form expected final path
            var expected = parms[0].Concat(parms[1].Skip(2));

            // act
            var newSut = sut.ConcatNew(extraPath.GetSubPaths().ToList()[1]);

            // assert
            Assert.Equal(parms[0].Length + parms[1].Length - 2, newSut.Count());
            Assert.Equal(parms[0].Length + parms[1].Length - 2, newSut.Length);
            Assert.Equal(expected, newSut.Select(x => x.FullName));
        }
        public void ConcatNew_ShouldMaintainOldChain(params string[] parms)
        {
            // arrange
            var extraPath = new CodePath();
            var sut       = new CodePath();

            foreach (var name in parms)
            {
                var mockedMethod = Mock.Create <Method>();
                Mock.Arrange(() => mockedMethod.FullName).Returns(name);
                extraPath.AddLast(mockedMethod);
                sut.AddLast(mockedMethod);
            }

            // act
            sut.ConcatNew(extraPath);

            // assert
            var actualCount = sut.Count();

            Assert.Equal(parms.Length, actualCount);
            Assert.Equal(parms.Length, sut.Length);

            var index = 0;

            foreach (var method in sut)
            {
                Assert.Equal(parms[index++], method.FullName);
            }
        }
        public void AddLastNew_AddMultiple_ShouldAddAllNodes(params string[] parms)
        {
            // arrange
            var sut  = new CodePath();
            var list = new List <Method>();

            foreach (var name in parms)
            {
                var mockedMethod = Mock.Create <Method>();
                Mock.Arrange(() => mockedMethod.FullName).Returns(name);
                list.Add(mockedMethod);
            }

            // act
            foreach (var method in list)
            {
                sut = sut.AddLastNew(method);
            }


            // assert
            Assert.Equal(parms.Length, sut.Count());
            Assert.Equal(parms.Length, sut.Length);
            foreach (var pair in sut.Zip(parms, (x, y) => new KeyValuePair <Method, String>(x, y)))
            {
                Assert.Equal(pair.Value, pair.Key.FullName);
            }
        }
        public void Equals_EqualPaths_ShouldReturnTrue(params string[] parms)
        {
            // arrange
            var extraPath = new CodePath();
            var sut1      = new CodePath();

            foreach (var name in parms)
            {
                var mockedMethod = Mock.Create <Method>();
                Mock.Arrange(() => mockedMethod.FullName).Returns(name);
                sut1.AddLast(mockedMethod);
            }

            var sut2 = new CodePath();

            foreach (var name in parms)
            {
                var mockedMethod = Mock.Create <Method>();
                Mock.Arrange(() => mockedMethod.FullName).Returns(name);
                sut2.AddLast(mockedMethod);
            }

            // act
            var actual = sut1.Equals(sut2);

            // assert
            Assert.Equal(parms.Length, sut1.Length);
            Assert.Equal(parms.Length, sut2.Length);
            Assert.True(actual);
        }
        static ListViewEvent()
        {
            CodePath.New <ListView>().Select(0);
            select = CodePath.Last;

            CodePath.New <ListView>().TryUnSelectAll();
            tryUnSelectAll = CodePath.Last;
        }
        public virtual void BindData(Applications applicationsWithWindow)
        {
            applications.DataSource    = applicationsWithWindow;
            applications.DisplayMember = CodePath.Get(CodePath.New <Application>().Name);

            windows.DisplayMember    = CodePath.Get(CodePath.New <DummyWindow>().Title);
            windowTabs.DisplayMember = CodePath.Get(CodePath.New <Tab>().PrimaryIdentification);
        }
Beispiel #9
0
        static TreeNodeClickedEvent()
        {
            CodePath.New <TreeNode>().Collapse();
            collapseEventName = CodePath.Last;

            CodePath.New <TreeNode>().Expand();
            expandEventName = CodePath.Last;
        }
 public virtual void BindData(RecordingOptions recordingOptions)
 {
     core.DataBindings.Add("Checked", recordingOptions, CodePath.Get(CodePath.New <RecordingOptions>().Core), false,
                           DataSourceUpdateMode.OnPropertyChanged);
     screenRepository.DataBindings.Add("Checked", recordingOptions, CodePath.Get(CodePath.New <RecordingOptions>().ScreenRepository), false,
                                       DataSourceUpdateMode.OnPropertyChanged);
     bulkText.DataBindings.Add("Checked", recordingOptions, CodePath.Get(CodePath.New <RecordingOptions>().BulkText), false,
                               DataSourceUpdateMode.OnPropertyChanged);
 }
Beispiel #11
0
        public CodePath ToCodePath()
        {
            var path   = new CodePath();
            var idList = this.Ids.Split(',');

            foreach (var id in idList)
            {
                path.AddLast(new MockMethod(int.Parse(id)));
            }

            return(path);
        }
        public void GetSubPaths_SubPathsHaveValidProperties(params string[] parms)
        {
            // arrange
            var sut = new CodePath();

            foreach (var name in parms)
            {
                var mockedMethod = Mock.Create <Method>();
                Mock.Arrange(() => mockedMethod.FullName).Returns(name);
                sut.AddLast(mockedMethod);
            }

            // act
            var subPathsList = sut.GetSubPaths().ToList();

            // assert
            for (int i = 0; i < subPathsList.Count; i++)
            {
                var currentPath = subPathsList[i];
                Assert.Equal(sut.Length - i - 1, currentPath.Length);
                Assert.Equal(sut.ElementAt(i + 1), currentPath.FirstMethod);
                Assert.Equal(sut.LastMethod, currentPath.LastMethod);
            }
        }
        public void AddLast_AddMultiple_ShouldHaveProperLength(params string[] parms)
        {
            // arrange
            var sut  = new CodePath();
            var list = new List <Method>();

            foreach (var name in parms)
            {
                var mockedMethod = Mock.Create <Method>();
                Mock.Arrange(() => mockedMethod.FullName).Returns(name);
                list.Add(mockedMethod);
            }

            // act
            foreach (var method in list)
            {
                sut.AddLast(method);
            }

            Assert.Equal(parms.Length, sut.Count());

            // assert
            Assert.Equal(parms.Length, sut.Length);
        }
Beispiel #14
0
        private bool IsCodePathAnIfPath(CodePath path)
        {
            HLInstruction instruction = path.GetFirstInstruction();
            bool          foundOneIf  = false;

            while (instruction != null)
            {
                if (instruction.IsConditionalBranch && instruction.ProcessedStackValue != null)
                {
                    foundOneIf = true;
                }
                else
                {
                    if (instruction.ProcessedStackValue != null)
                    {
                        return(false);
                    }
                }

                instruction = instruction.GetNextInstruction();
            }

            return(foundOneIf);
        }
 static ListControlEvent()
 {
     CodePath.New <ComboBox>().Select(null);
     actionName = CodePath.Last;
 }
 static TextBoxEvent()
 {
     textAction = CodePath.Get(CodePath.New <TextBox>().Text);
     CodePath.New <TextBox>().BulkText = null;
     bulkTextAction = CodePath.Last;
 }
 static TreeNodeSelectEvent()
 {
     CodePath.New <TreeNode>().Select();
     selectEventName = CodePath.Last;
 }
Beispiel #18
0
 static TabEvent()
 {
     CodePath.New <Tab>().SelectTabPage(null);
     action = CodePath.Last;
 }
Beispiel #19
0
        private void ProcessCodePath(TextWriter writer, CodePath path, string indent)
        {
            HLInstruction instruction = path.GetFirstInstruction();

            while (instruction != null)
            {
                Annotate(writer, indent, instruction);

                if (instruction.UnconditionalBranch)
                {
                    // Not used
                }
                else if (instruction.IsConditionalBranch)
                {
                    if (_nextIfIsAnElseIf)
                    {
                        writer.Write(string.Format("{0}else if", indent));
                        _nextIfIsAnElseIf = false;
                    }
                    else
                    {
                        writer.Write(string.Format("{0}if", indent));
                    }
                    writer.WriteLine(string.Format(" ({0})", instruction.ProcessedStackValue));
                    writer.WriteLine(indent + "{");
                    ProcessCodePath(writer, instruction.BranchCodesPaths[instruction.DefaultConditional],
                                    indent + "    ");
                    writer.WriteLine(indent + "}");

                    if (instruction.BranchCodesPaths.ContainsKey(!instruction.DefaultConditional))
                    {
                        CodePath elsePath = instruction.BranchCodesPaths[!instruction.DefaultConditional];
                        if (elsePath.StartInstruction != null)
                        {
                            if (IsCodePathAnIfPath(elsePath))
                            {
                                _nextIfIsAnElseIf = true;
                                ProcessCodePath(writer, elsePath, indent);
                            }
                            else
                            {
                                writer.WriteLine(indent + "else");
                                writer.WriteLine(indent + "{");
                                ProcessCodePath(writer, elsePath, indent + "    ");
                                writer.WriteLine(indent + "}");
                            }
                        }
                    }
                }
                else if (instruction.IsSwitchBranch)
                {
                    // Do switch cases ever fall through?? I'm assuming they don't here!

                    writer.WriteLine(indent + string.Format("switch ({0})", instruction.ProcessedStackValue));
                    writer.WriteLine(indent + "{");

                    // Keep track of code paths are have already outputted to keep
                    // track of offsets that lead to the same codepath
                    var swDonePaths = new List <CodePath>();

                    foreach (var item in instruction.BranchCodesPaths)
                    {
                        if (swDonePaths.Contains(item.Value))
                        {
                            continue;
                        }

                        foreach (var item2 in instruction.BranchCodesPaths)
                        {
                            // O(n^2) loop here, there's probably a better way to optimize it

                            if (item2.Value == item.Value)
                            {
                                if (item2.Key.GetType() == typeof(int))
                                {
                                    writer.WriteLine(string.Format("{0}    case {1}:", indent, LiteralFormatter.FormatInteger((int)item2.Key)));
                                }
                                else
                                {
                                    writer.WriteLine(string.Format("{0}    default:", indent));
                                }
                            }
                        }

                        writer.WriteLine(indent + "    {");
                        ProcessCodePath(writer, item.Value, indent + "        ");
                        if (item.Value.EndInstruction == null || !item.Value.EndInstruction.ExitFunction)
                        {
                            writer.WriteLine(indent + "        break;");
                        }
                        writer.WriteLine(indent + "    }");

                        swDonePaths.Add(item.Value);
                    }

                    writer.WriteLine(indent + "}");
                }
                else if (instruction.LoopCodePath != null)
                {
                    // First of a loop instruction (hopefully, someday, this will be extracted out by the ProgramAnalyzer)
                    // Can we ever break out of a loop? I assume we can't here!

                    while (!instruction.IsConditionalBranch)
                    {
                        instruction = instruction.NextInstruction;
                        Annotate(writer, indent, instruction);
                    }

                    writer.WriteLine(indent + string.Format("while ({0})", instruction.ProcessedStackValue));
                    writer.WriteLine(indent + "{");
                    ProcessCodePath(writer, instruction.BranchCodesPaths[true], indent + "    ");
                    writer.WriteLine(indent + "}");
                }
                else
                {
                    WriteInstruction(writer, instruction, indent);
                }

                instruction = instruction.NextInstruction;
            }
        }
Beispiel #20
0
        private void ProcessCodePath(TextWriter writer, CodePath path, string indent)
        {
            HLInstruction instruction = path.GetFirstInstruction();

            while (instruction != null)
            {
                if (instruction.IsConditionalBranch)
                {
                    writer.WriteLine(string.Format("{0}.if{1}", indent, instruction.DefaultConditional ? "true" : "false"));
                    ProcessCodePath(writer, instruction.BranchCodesPaths[instruction.DefaultConditional],
                                    indent + "    ");

                    if (instruction.BranchCodesPaths.ContainsKey(!instruction.DefaultConditional))
                    {
                        CodePath elsePath = instruction.BranchCodesPaths[!instruction.DefaultConditional];

                        if (elsePath.StartInstruction != null)
                        {
                            writer.WriteLine(indent + ".else");
                            ProcessCodePath(writer, elsePath,
                                            indent + "    ");
                        }
                    }

                    writer.WriteLine(indent + ".endif");
                }
                else if (instruction.IsSwitchBranch)
                {
                    // Do switch cases ever fall through?? I'm assuming they don't here!

                    writer.WriteLine(indent + ".switch");

                    // Keep track of code paths are have already outputted to keep
                    // track of offsets that lead to the same codepath
                    var swDonePaths = new List <CodePath>();

                    foreach (var item in instruction.BranchCodesPaths)
                    {
                        if (swDonePaths.Contains(item.Value))
                        {
                            continue;
                        }

                        foreach (var item2 in instruction.BranchCodesPaths)
                        {
                            // O(n^2) loop here, there's probably a better way to optimize it

                            if (item2.Value == item.Value)
                            {
                                if (item2.Key.GetType() == typeof(int))
                                {
                                    writer.WriteLine(string.Format("{0}    .case {1}", indent, item2.Key));
                                }
                                else
                                {
                                    writer.WriteLine(string.Format("{0}    .default", indent, item2.Key));
                                }
                            }
                        }

                        ProcessCodePath(writer, item.Value, indent + "        ");
                        if (item.Value.EndInstruction == null || !item.Value.EndInstruction.ExitFunction)
                        {
                            writer.WriteLine(indent + "        .break");
                        }

                        swDonePaths.Add(item.Value);
                    }

                    writer.WriteLine(indent + ".endswitch");
                }
                else if (instruction.LoopCodePath != null)
                {
                    // First of a loop instruction (hopefully, someday, this will be extracted out by the ProgramAnalyzer)
                    // Can we ever break out of a loop? I assume we can't here!

                    writer.WriteLine(indent + ".while");
                    instruction = WriteLoopConditional(writer, instruction, indent + "    ");
                    writer.WriteLine(indent + ".do");
                    ProcessCodePath(writer, instruction.BranchCodesPaths[true], indent + "    ");
                    writer.WriteLine(indent + ".endwhile");
                }
                else
                {
                    WriteInstruction(writer, instruction, indent);
                }

                instruction = instruction.GetNextInstruction();
            }
        }
 static UIItemClickEvent()
 {
     CodePath.New <UIItem>().Click();
     actionName = CodePath.Last;
 }
Beispiel #22
0
        /// <summary>
        /// LUA结构支持
        /// </summary>
        /// <returns></returns>
        public override void GetLuaStruct(StringBuilder code)
        {
            base.GetLuaStruct(code);
            int idx;

            idx = 0;
            code.AppendLine("['ApiItems'] ={");
            foreach (var val in ApiItems)
            {
                if (idx++ > 0)
                {
                    code.Append(',');
                }
                code.AppendLine($@"{val.GetLuaStruct()}");
            }
            code.AppendLine("},");

            idx = 0;
            code.AppendLine("['Entities'] ={");
            foreach (var val in Entities)
            {
                if (idx++ > 0)
                {
                    code.Append(',');
                }
                code.AppendLine($@"{val.GetLuaStruct()}");
            }
            code.AppendLine("},");

            code.AppendLine($@"['ReadOnly'] ={(ReadOnly.ToString().ToLower())},");

            if (!string.IsNullOrWhiteSpace(DataBaseObjectName))
            {
                code.AppendLine($@"['DataBaseObjectName'] = '{DataBaseObjectName.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DataBaseObjectName'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(NameSpace))
            {
                code.AppendLine($@"['NameSpace'] = '{NameSpace.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['NameSpace'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(PagePath))
            {
                code.AppendLine($@"['PagePath'] = '{PagePath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['PagePath'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(BusinessPath))
            {
                code.AppendLine($@"['BusinessPath'] = '{BusinessPath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['BusinessPath'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ClientCsPath))
            {
                code.AppendLine($@"['ClientCsPath'] = '{ClientCsPath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ClientCsPath'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(ModelPath))
            {
                code.AppendLine($@"['ModelPath'] = '{ModelPath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['ModelPath'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(CodePath))
            {
                code.AppendLine($@"['CodePath'] = '{CodePath.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['CodePath'] = nil,");
            }

            code.AppendLine($@"['DbType'] ='{DbType}',");

            if (!string.IsNullOrWhiteSpace(DbHost))
            {
                code.AppendLine($@"['DbHost'] = '{DbHost.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DbHost'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(DbSoruce))
            {
                code.AppendLine($@"['DbSoruce'] = '{DbSoruce.ToLuaString()}',");
            }
            else
            {
                code.AppendLine($@"['DbSoruce'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(DbPassWord))
            {
                code.AppendLine($@"['DbPassWord'] = '******',");
            }
            else
            {
                code.AppendLine($@"['DbPassWord'] = nil,");
            }

            if (!string.IsNullOrWhiteSpace(DbUser))
            {
                code.AppendLine($@"['DbUser'] = '******',");
            }
            else
            {
                code.AppendLine($@"['DbUser'] = nil,");
            }
        }
 protected override string ActionName(EventOption eventOption)
 {
     CodePath.New <RadioButton>().Select();
     return(CodePath.Last);
 }