public void Discovery_IgnoresNonAnnotatedTestCleanupInGivenNonTestModule() { var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("TestProject1", vbext_ProjectProtection.vbext_pp_none) .AddComponent("TestModule1", vbext_ComponentType.vbext_ct_StdModule, GetNormalModuleInput.Replace("'@TestCleanup", string.Empty)); var vbe = builder.AddProject(project.Build()).Build(); var mockHost = new Mock <IHostApplication>(); mockHost.SetupAllProperties(); var parser = MockParser.Create(vbe.Object, new RubberduckParserState(new Mock <ISinks>().Object)); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var component = project.MockComponents.Single(f => f.Object.Name == "TestModule1").Object; var qualifiedModuleName = new QualifiedModuleName(component); var initMethods = qualifiedModuleName.FindTestCleanupMethods(parser.State); Assert.IsFalse(initMethods.Any()); }
public void Discovery_DiscoversAnnotatedTestCleanupInGivenTestModule() { var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("TestProject1", vbext_ProjectProtection.vbext_pp_none) .AddComponent("TestModule1", vbext_ComponentType.vbext_ct_StdModule, GetTestModuleInput) .AddComponent("TestModule2", vbext_ComponentType.vbext_ct_StdModule, GetTestModuleInput); var vbe = builder.AddProject(project.Build()).Build(); var mockHost = new Mock <IHostApplication>(); mockHost.SetupAllProperties(); var parser = MockParser.Create(vbe.Object, new RubberduckParserState(new Mock <ISinks>().Object)); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var component = project.MockComponents.Single(f => f.Object.Name == "TestModule1").Object; var qualifiedModuleName = new QualifiedModuleName(component); var initMethods = qualifiedModuleName.FindTestCleanupMethods(parser.State).ToList(); Assert.AreEqual(1, initMethods.Count); Assert.AreEqual("TestModule1", initMethods.ElementAt(0).QualifiedModuleName.ComponentName); Assert.AreEqual("TestCleanup", initMethods.ElementAt(0).MemberName); }
public void Discovery_DiscoversAnnotatedTestCleanupInGivenTestModule() { 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; var parser = MockParser.Create(vbe); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var component = project.MockComponents.Single(f => f.Object.Name == "TestModule1").Object; var qualifiedModuleName = new QualifiedModuleName(component); var initMethods = qualifiedModuleName.FindTestCleanupMethods(parser.State).ToList(); Assert.AreEqual(1, initMethods.Count); Assert.AreEqual("TestModule1", initMethods.ElementAt(0).QualifiedName.QualifiedModuleName.ComponentName); Assert.AreEqual("TestCleanup", initMethods.ElementAt(0).QualifiedName.MemberName); }
public void Discovery_IgnoresNonAnnotatedTestCleanupInGivenNonTestModule() { var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("TestProject1", ProjectProtection.Unprotected) .AddComponent("TestModule1", ComponentType.StandardModule, GetNormalModuleInput.Replace("'@TestCleanup", 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 = qualifiedModuleName.FindTestCleanupMethods(state); Assert.IsFalse(initMethods.Any()); } }
public void Discovery_DiscoversAnnotatedTestCleanupInGivenTestModule() { 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 = qualifiedModuleName.FindTestCleanupMethods(state).ToList(); Assert.AreEqual(1, initMethods.Count); Assert.AreEqual("TestModule1", initMethods.ElementAt(0).QualifiedName.QualifiedModuleName.ComponentName); Assert.AreEqual("TestCleanup", initMethods.ElementAt(0).QualifiedName.MemberName); } }
public void Discovery_IgnoresNonAnnotatedTestCleanupInGivenNonTestModule() { var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("TestProject1", ProjectProtection.Unprotected) .AddComponent("TestModule1", ComponentType.StandardModule, GetNormalModuleInput.Replace("'@TestCleanup", string.Empty)); var vbe = builder.AddProject(project.Build()).Build().Object; var parser = MockParser.Create(vbe); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var component = project.MockComponents.Single(f => f.Object.Name == "TestModule1").Object; var qualifiedModuleName = new QualifiedModuleName(component); var initMethods = qualifiedModuleName.FindTestCleanupMethods(parser.State); Assert.IsFalse(initMethods.Any()); }