public void Given_ValidFileWithTwoEntries_When_ReadToolParserInfoReturned_Exptected_ListWithTwoEntries()
        {
            ToolParserConfiguration     toolConfiguration = new ToolParserConfiguration();
            List <ToolParserInfoFormat> actualValue       = toolConfiguration.ReadToolParserInfo(@"..\..\..\ToolParserConfigurationLib.Test\TestFiles\ToolsXmlParserInfo.xml");
            List <ToolParserInfoFormat> exptectedValue    = new List <ToolParserInfoFormat>();

            actualValue.Add(new ToolParserInfoFormat("StyleCopDataParserLib.StyleCopDataParser",
                                                     "..\\..\\..\\StyleCopDataParserLib\\bin\\Debug\\StyleCopDataParserLib.dll"));
            actualValue.Add(new ToolParserInfoFormat("FxCopDataParserLib.FxCopDataParser",
                                                     "..\\..\\..\\FxCopDataParserLib\\bin\\Debug\\FxCopDataParserLib.dll"
                                                     ));

            int k = 1;

            foreach (var i in actualValue)
            {
                foreach (var j in exptectedValue)
                {
                    if (i.DllPath != j.DllPath || i.Name != j.Name)
                    {
                        k = 0;
                        break;
                    }
                }
            }

            Assert.AreEqual(1, k);
        }
        public void Given_ValidFileWithTwoEntry_When_ReadToolParserInfoReturned_Exptected_ListSizeTwo()
        {
            ToolParserConfiguration     toolConfiguration = new ToolParserConfiguration();
            List <ToolParserInfoFormat> toolOutputs       = toolConfiguration.ReadToolParserInfo(@"..\..\..\ToolParserConfigurationLib.Test\TestFiles\ToolsXmlParserInfo.xml");
            int actualValue   = toolOutputs.Count;
            int expectedValue = 2;

            Assert.AreEqual(actualValue, expectedValue);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// It is for parsing the xml files
        /// </summary>
        public void ParseXMlFiles(List <string> input)
        {
            try
            {
                string filePath = "..\\ToolsXmlParserInfo.xml";
                ToolParserConfiguration     toolParserConfiguration = new ToolParserConfiguration();
                List <ToolParserInfoFormat> toolParserInfo          = toolParserConfiguration.ReadToolParserInfo(filePath);
                int j = 1;
                foreach (var i in toolParserInfo)
                {
                    string startupPath = System.IO.Directory.GetCurrentDirectory();
                    Console.WriteLine("startupPath= " + startupPath);
                    Console.WriteLine(i.DllPath + "  " + i.Name);
#pragma warning disable S3885 // "Assembly.Load" should be used
                    Assembly assembly = Assembly.LoadFrom(i.DllPath);
#pragma warning restore S3885 // "Assembly.Load" should be used
                    var v = assembly.CreateInstance(i.Name) as IToolDataParser;
                    foreach (var file in input)
                    {
                        if (i.Name.Contains("StyleCop") && file.Contains("cs"))
                        {
                            string path = "..\\GeneratedFiles\\" + j + ".xml";
                            Console.WriteLine(path);
                            ToolsOutputData.AddRange(v.Parse(path));
                        }
                        if (i.Name.Contains("FxCop") && file.Contains("exe"))
                        {
                            string path = "..\\GeneratedFiles\\" + j + ".xml";
                            Console.WriteLine(path);
                            ToolsOutputData.AddRange(v.Parse(path));
                        }

                        j++;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw new FileNotFoundException();
            }
        }
        public void Given_InvalidFile_When_ReadToolParserInfoInvoked_Exptected_FileNotFoundException()
        {
            ToolParserConfiguration toolConfiguration = new ToolParserConfiguration();

            toolConfiguration.ReadToolParserInfo("abc");
        }