public void Discovery_IgnoresNonAnnotatedModuleInitInGivenNonTestModule() { var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("TestProject1", ProjectProtection.Unprotected) .AddComponent("TestModule1", ComponentType.StandardModule, GetNormalModuleInput.Replace("'@ModuleInitialize", string.Empty)); var vbe = builder.AddProject(project.Build()).Build().Object; using (var state = MockParser.CreateAndParse(vbe)) { var component = project.MockComponents.Single(f => f.Object.Name == "TestModule1").Object; var qualifiedModuleName = new QualifiedModuleName(component); var initMethods = TestDiscovery.FindModuleInitializeMethods(qualifiedModuleName, state); Assert.IsFalse(initMethods.Any()); } }
public void Discovery_DiscoversAnnotatedModuleInitInGivenTestModule() { var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("TestProject1", ProjectProtection.Unprotected) .AddComponent("TestModule1", ComponentType.StandardModule, GetTestModuleInput) .AddComponent("TestModule2", ComponentType.StandardModule, GetTestModuleInput); var vbe = builder.AddProject(project.Build()).Build().Object; using (var state = MockParser.CreateAndParse(vbe)) { var component = project.MockComponents.Single(f => f.Object.Name == "TestModule1").Object; var qualifiedModuleName = new QualifiedModuleName(component); var initMethods = TestDiscovery.FindModuleInitializeMethods(qualifiedModuleName, state).ToList(); Assert.AreEqual(1, initMethods.Count); Assert.AreEqual("TestModule1", initMethods.ElementAt(0).QualifiedName.QualifiedModuleName.ComponentName); Assert.AreEqual("ModuleInitialize", initMethods.ElementAt(0).QualifiedName.MemberName); } }