public void ShouldVisitEachNamespace() { var proj = DTETransformer.BuildDteProject(new Type[] { typeof(LocalModel), typeof(ModelFromDifferentProject) }, projectName: "proj"); int callCount = 0; var expectedNames = new string[] { "T4TS.Tests.Traversal.Models", "T4TS.Example.Models" }; new ProjectTraverser(proj, (ns) => { Assert.AreEqual(expectedNames[callCount++], ns.Name); }); Assert.AreEqual(2, callCount); }
public void ShouldVisitEachCodeClass() { var project = DTETransformer.BuildDteProject(new Type[] { typeof(M), typeof(N) }, projectName: "NamespaceTraverserTests"); int callCount = 0; var expectedNames = new string[] { "M", "N" }; ProjectItem projectItem; if (TryGetSingle(project.ProjectItems.GetEnumerator(), out projectItem)) { foreach (CodeNamespace ns in projectItem.FileCodeModel.CodeElements) { Traversal.TraverseClassesInNamespace(ns, (c) => { Assert.AreEqual(expectedNames[callCount++], c.Name); }); } } Assert.AreEqual(2, callCount); }
public void ShouldVisitSubProjectItems() { var subProjItem = DTETransformer.BuildDteProjectItem(new Type[] { typeof(ModelFromDifferentProject) }, projectItemName: "subProj"); var moqSubProjectItems = new Mock <ProjectItems>(); moqSubProjectItems.Setup(x => x.GetEnumerator()).Returns(() => new[] { subProjItem }.GetEnumerator()); var proj = DTETransformer.BuildDteProject(new Type[] { typeof(LocalModel) }, projectName: "proj", subProjectItems: moqSubProjectItems.Object); int callCount = 0; var expectedNames = new string[] { "T4TS.Tests.Models", "T4TS.Example.Models" }; T4TS.Traversal.TraverseNamespacesInProject(proj, (ns) => { Assert.AreEqual(expectedNames[callCount++], ns.Name); }); Assert.AreEqual(2, callCount); }