public void EqualsTest() { Stream cs1Stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Citities.Library.Test.Files.Cs1.txt"); StreamReader cs1Reader = new StreamReader(cs1Stream); string cs1Text = cs1Reader.ReadToEnd(); CsParser cs1Parser = new CsParser(); ParseResult cs1Result = cs1Parser.Parse(cs1Text); Entity cs1Entity1 = new Entity(cs1Result, DateTime.Now, 1); Entity cs1Entity2 = new Entity(cs1Result, DateTime.Now, 2); Entity cs1Entity3 = new Entity(cs1Result, DateTime.Now, 1); Stream cs2Stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Citities.Library.Test.Files.Cs2.txt"); StreamReader cs2Reader = new StreamReader(cs2Stream); string cs2Text = cs2Reader.ReadToEnd(); CsParser cs2Parser = new CsParser(); ParseResult cs2Result = cs2Parser.Parse(cs2Text); Entity cs2Entity1 = new Entity(cs2Result, DateTime.Now, 1); Entity cs2Entity2 = new Entity(cs2Result, DateTime.Now, 2); Assert.AreNotEqual(cs2Entity2, cs2Entity1); Assert.AreNotEqual(cs1Entity2, cs1Entity1); Assert.AreEqual(cs1Entity1, cs1Entity3); }
/// <summary> /// Creates a collection of entities from a collection go IFiles. /// </summary> /// <returns>The entities.</returns> /// <param name="files">Files.</param> public static EntityCollection MakeEntities(IEnumerable <IFile> files) { EntityCollection entities = new EntityCollection(); ParallelOptions parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = 8 }; switch (CheckProjectType(files)) { case ProjectType.CSharp: CsParser csParser = new CsParser(); Parallel.ForEach(files.Where(x => Path.GetExtension(x.Path) == ".cs"), parallelOptions, item => { entities.Add(csParser.Parse(item), item.Date.DateTime, item.Revisions); }); break; case ProjectType.Unicon: IcnParser icnParser = new IcnParser(); Parallel.ForEach(files.Where(x => Path.GetExtension(x.Path) == ".icn"), parallelOptions, item => { entities.Add(icnParser.Parse(item), item.Date.DateTime, item.Revisions); }); break; case ProjectType.Java: JavaParser javaParser = new JavaParser(); Parallel.ForEach(files.Where(x => Path.GetExtension(x.Path) == ".java"), parallelOptions, item => { entities.Add(javaParser.Parse(item), item.Date.DateTime, item.Revisions); }); break; } return(entities); }
public void InnerClasssGenerateTest() { CsParser parser = new CsParser(); string code = File.ReadAllText("Content\\CsParserTests\\InnerClass.cs"); var classes = parser.Parse(code); classes.Should().ContainSingle("because there is a single class in the file, the inner class is ignored"); }
public void NonPublicClassesGenerateTest() { CsParser parser = new CsParser(); string code = File.ReadAllText("Content\\CsParserTests\\NonPublicClasses.cs"); var classes = parser.Parse(code); classes.Should().BeEmpty("because the classes are not public"); }
public void MultipleClassesGenerateTest() { CsParser parser = new CsParser(); string code = File.ReadAllText("Content\\CsParserTests\\MultipleClassesModel.cs"); var classes = parser.Parse(code); classes.Should().HaveCount(2, "because there are two classes in the file"); }
public void NonPublicPropertiesGenerateTest() { CsParser parser = new CsParser(); string code = File.ReadAllText("Content\\CsParserTests\\NonPublicProperties.cs"); var classes = parser.Parse(code); classes.Should().ContainSingle("because there is a single class in the file"); var @class = classes.Single(); @class.Properties.Should().HaveCount(0, "because non of the properties are public"); }
public void SimpleModelGenerateTest() { CsParser parser = new CsParser(); string code = File.ReadAllText("Content\\CsParserTests\\SimpleModel.cs"); var classes = parser.Parse(code); classes.Should().ContainSingle("because there is a single class in the model"); var @class = classes.Single(); @class.Name.Should().Be("SimpleModel", "because the model is named SimpleModel"); @class.Properties.Should().HaveCount(17, "because there are 17 properties in the model"); }
public void Test() { const string fileName = @"..\..\ParseNode.cs"; var parser = new CsParser(); var node = parser.Parse(new FileInfo(fileName)); var element = node.GetXml(); Assert.Greater(node.Children.Count(), 0); }