public void BuildFile_CSharpInterface_ContainsSubstring(string[] expectedSubstrings,
                                                                string[] inputProperties,
                                                                string[] inputMethods)
        {
            InterfaceInfo oInterfaceInfo = new InterfaceInfo();

            oInterfaceInfo.InterfaceName = nameof(BuildFile_CSharpInterface_ContainsSubstring);
            oInterfaceInfo.AddProperties(inputProperties);
            oInterfaceInfo.AddMethods(inputMethods);

            string[] files = Services.CodeBuilderService.GenerateFiles("CSharp", null, new InterfaceInfo[] { oInterfaceInfo });

            string actualFile   = files.First();
            string actualString = System.IO.File.ReadAllText(actualFile);

            foreach (string expectedSubstring in expectedSubstrings)
            {
                Assert.Contains(expectedSubstring, actualString);
            }
        }
示例#2
0
        private void AddRepositoryInterface(List <InterfaceInfo> interfaceCollection)
        {
            if (RepositoryMethods == null || RepositoryMethods.Rows.Count == 0)
            {
                return;
            }

            InterfaceInfo oInterfaceInfo = new InterfaceInfo();

            oInterfaceInfo.Namespace        = "Repository";
            oInterfaceInfo.InterfaceName    = "I" + this.lblRepository.Text;
            oInterfaceInfo.ImplementedTypes = new string[] { "IDisposable", $"IEnumerable({this.txtRepositoryName.Text}Info)" };

            if (RepositoryMethods != null)
            {
                oInterfaceInfo.AddMethods((from DataRow oRow in RepositoryMethods.Rows
                                           select((string)oRow["Value"]).Replace("{RepositoryName}", this.txtRepositoryName.Text)).ToArray());
            }

            interfaceCollection.Add(oInterfaceInfo);
        }