Example #1
0
 public override void TestInitialize()
 {
     base.TestInitialize();
     this.testConfiguration         = BuildManagerContainerConfiguration.Default;
     this.testExtensionContainer    = this.Operations.GenerateContainer(this.testConfiguration);
     this.buildManagerTestExtension = this.testExtensionContainer.GetFirstTestExtension <BuildManagerTestExtension>();
 }
Example #2
0
 public override void TestCleanup()
 {
     base.TestCleanup();
     Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.UnloadAllProjects();
     this.buildManagerTestExtension.Dispose();
     this.buildManagerTestExtension = null;
     this.testConfiguration.Dispose();
     this.testConfiguration      = null;
     this.testExtensionContainer = null;
 }
Example #3
0
        /// <summary>
        /// Responsible for creating the build manager.
        /// For MSBuild backend testing BuildManager is the Entry point for all tests. That is - the environment
        /// for testing starts with the BuildManager. Configuration can specify which components should be mocked
        /// and which test extension should be attached to which component.
        /// </summary>
        /// <returns>TextExtensions created.</returns>
        protected override TestExtensionContainer Generate()
        {
            List <TestExtension> testExtensions = new List <TestExtension>();

            // To workaround the problem where extensions derived out from Testextension does not have a LifeTimeManagmentService.
            LifeTimeManagmentServiceTestExtension lifetimeServiceExtension = new LifeTimeManagmentServiceTestExtension(LifetimeService);

            LifetimeService.Compose(lifetimeServiceExtension);
            testExtensions.Add(lifetimeServiceExtension);

            // Create the build manager and the associated test extension first.
            BuildManagerTestExtension buildManagerTestExtension = new BuildManagerTestExtension(BuildManager.DefaultBuildManager);

            LifetimeService.Compose(buildManagerTestExtension);
            testExtensions.Add(buildManagerTestExtension);

            // When the BuildManager is created it registers a default set of components.
            // Loop through each of the components that we want to mock and then replace the component in the BuildManager.
            foreach (KeyValuePair <ComponentType, string> componentTypePair in this.Configuration.ComponentsToMock)
            {
                buildManagerTestExtension.ReplaceRegisterdFactory(GetBuildComponentTypeFromComponentType(componentTypePair.Key.ToString()), this.CreateMockComponent);
            }

            // Loop through each of the components that we want to wrap with a test extension - create the test extension and aggregate the internal component.
            // This component could be a mock that we create above or the real implementation.
            foreach (KeyValuePair <ComponentType, string> componentTypePair in this.Configuration.TestExtensionForComponents)
            {
                TestExtension extension = CreateTestExtensionForComponent(componentTypePair.Key.ToString(), componentTypePair.Value, buildManagerTestExtension);
                LifetimeService.Compose(extension);
                testExtensions.Add(extension);
            }

            TestExtensionContainer testContainer = new TestExtensionContainer(testExtensions);

            return(testContainer);
        }
 public override void TestCleanup()
 {
     base.TestCleanup();
     Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.UnloadAllProjects();
     this.buildManagerTestExtension.Dispose();
     this.buildManagerTestExtension = null;
     this.testConfiguration.Dispose();
     this.testConfiguration = null;
     this.testExtensionContainer = null;
 }
 public override void TestInitialize()
 {
     base.TestInitialize();
     this.testConfiguration = BuildManagerContainerConfiguration.Default;
     this.testExtensionContainer = this.Operations.GenerateContainer(this.testConfiguration);
     this.buildManagerTestExtension = this.testExtensionContainer.GetFirstTestExtension<BuildManagerTestExtension>();
 }