Exemplo n.º 1
0
        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 = TestDiscovery.FindTestCleanupMethods(qualifiedModuleName, state);
                Assert.IsFalse(initMethods.Any());
            }
        }
Exemplo n.º 2
0
        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 = TestDiscovery.FindTestCleanupMethods(qualifiedModuleName, state).ToList();

                Assert.AreEqual(1, initMethods.Count);
                Assert.AreEqual("TestModule1", initMethods.ElementAt(0).QualifiedName.QualifiedModuleName.ComponentName);
                Assert.AreEqual("TestCleanup", initMethods.ElementAt(0).QualifiedName.MemberName);
            }
        }