Пример #1
0
        public void Discovery_IgnoresNonAnnotatedModuleCleanupInGivenNonTestModule()
        {
            var builder = new MockVbeBuilder();
            var project = builder.ProjectBuilder("TestProject1", ProjectProtection.Unprotected)
                          .AddComponent("TestModule1", ComponentType.StandardModule, GetNormalModuleInput.Replace("'@ModuleCleanup", 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.FindModuleCleanupMethods(qualifiedModuleName, state);
                Assert.IsFalse(initMethods.Any());
            }
        }
Пример #2
0
        public void Discovery_DiscoversAnnotatedModuleCleanupInGivenTestModule()
        {
            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.FindModuleCleanupMethods(qualifiedModuleName, state).ToList();

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