Esempio n. 1
0
        public static void TestRunSetup()
        {
            AzureSessionInitializer.InitializeAzureSession();
            // This is to ensure that all key assemblies are loaded before IOC registration is required.
            // This is only necessary for the test system as load order is correct for a production run.
            // types.Add(typeof(GetAzureHDInsightClusterCmdlet));
            var cmdletRunManager = ServiceLocator.Instance.Locate <IServiceLocationSimulationManager>();

            cmdletRunManager.RegisterType <IAzureHDInsightConnectionSessionManagerFactory, AzureHDInsightConnectionSessionManagerSimulatorFactory>();
            cmdletRunManager.RegisterType <IBufferingLogWriterFactory, BufferingLogWriterFactory>();
            cmdletRunManager.RegisterType <IAzureHDInsightStorageHandlerFactory, AzureHDInsightStorageHandlerSimulatorFactory>();
            cmdletRunManager.RegisterType <IAzureHDInsightSubscriptionResolverFactory, AzureHDInsightSubscriptionResolverSimulatorFactory>();
            cmdletRunManager.RegisterType <IAzureHDInsightClusterManagementClientFactory, AzureHDInsightClusterManagementClientSimulatorFactory>();
            cmdletRunManager.RegisterType <IAzureHDInsightJobSubmissionClientFactory, AzureHDInsightJobSubmissionClientSimulatorFactory>();
            var testManager = new IntegrationTestManager();

            AzureSession.Instance.DataStore = new MemoryDataStore();
            var profile = new AzureSMProfile(Path.Combine(AzureSession.Instance.ProfileDirectory, AzureSession.Instance.ProfileFile));

            AzureSMCmdlet.CurrentProfile = profile;
            TestCredentials = testManager.GetCredentials("default");
            if (TestCredentials == null)
            {
                Assert.Inconclusive("No entry was found in the credential config file for the specified test configuration.");
            }

            // Sets the certificate
            var defaultCertificate = new X509Certificate2(
                Convert.FromBase64String(TestCredentials.Certificate), string.Empty);

            // Sets the test static properties
            ClusterPrefix = string.Format("CLITest-{0}", Environment.GetEnvironmentVariable("computername") ?? "unknown");

            // Sets the credential objects
            var tempCredentials = new HDInsightCertificateCredential
            {
                SubscriptionId = TestCredentials.SubscriptionId,
                Certificate    = defaultCertificate
            };

            validCredentials = tempCredentials;
            tempCredentials  = new HDInsightCertificateCredential {
                SubscriptionId = Guid.NewGuid(), Certificate = defaultCertificate
            };
            invalidSubscriptionId = tempCredentials;
            invalidCertificate    = tempCredentials;
        }
        public static void TestRunSetup()
        {
            // This is to ensure that all key assemblies are loaded before IOC registration is required.
            // This is only necessary for the test system as load order is correct for a production run.
            // types.Add(typeof(GetAzureHDInsightClusterCmdlet));
            var cmdletRunManager = ServiceLocator.Instance.Locate<IServiceLocationSimulationManager>();
            cmdletRunManager.RegisterType<IAzureHDInsightConnectionSessionManagerFactory, AzureHDInsightConnectionSessionManagerSimulatorFactory>();
            cmdletRunManager.RegisterType<IBufferingLogWriterFactory, BufferingLogWriterFactory>();
            cmdletRunManager.RegisterType<IAzureHDInsightStorageHandlerFactory, AzureHDInsightStorageHandlerSimulatorFactory>();
            cmdletRunManager.RegisterType<IAzureHDInsightSubscriptionResolverFactory, AzureHDInsightSubscriptionResolverSimulatorFactory>();
            cmdletRunManager.RegisterType<IAzureHDInsightClusterManagementClientFactory, AzureHDInsightClusterManagementClientSimulatorFactory>();
            cmdletRunManager.RegisterType<IAzureHDInsightJobSubmissionClientFactory, AzureHDInsightJobSubmissionClientSimulatorFactory>();
            var testManager = new IntegrationTestManager();
            AzureSession.DataStore = new MemoryDataStore();
            var profile = new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            AzurePSCmdlet.CurrentProfile = profile;
            TestCredentials = testManager.GetCredentials("default");
            if (TestCredentials == null)
            {
                Assert.Inconclusive("No entry was found in the credential config file for the specified test configuration.");
            }

            // Sets the certificate
            var defaultCertificate = new X509Certificate2(
                    Convert.FromBase64String(TestCredentials.Certificate), string.Empty);
            // Sets the test static properties
            ClusterPrefix = string.Format("CLITest-{0}", Environment.GetEnvironmentVariable("computername") ?? "unknown");

            // Sets the credential objects
            var tempCredentials = new HDInsightCertificateCredential
            {
                SubscriptionId = TestCredentials.SubscriptionId,
                Certificate = defaultCertificate
            };

            validCredentials = tempCredentials;
            tempCredentials = new HDInsightCertificateCredential { SubscriptionId = Guid.NewGuid(), Certificate = defaultCertificate };
            invalidSubscriptionId = tempCredentials;
            invalidCertificate = tempCredentials;
        }