/// <summary>
        /// Initializes a new instance of the <see cref="GetAzureProviderFeatureCmdletTests"/> class.
        /// </summary>
        public RegisterAzureProviderPreviewFeatureCmdletTests(ITestOutputHelper output)
        {
            this.featureOperationsMock = new Mock <ISubscriptionFeatureRegistrationsOperations>();
            var featureClient = new Mock <IFeatureClient>();

            featureClient
            .SetupGet(client => client.SubscriptionFeatureRegistrations)
            .Returns(() => this.featureOperationsMock.Object);

            this.commandRuntimeMock = new Mock <ICommandRuntime>();

            this.commandRuntimeMock
            .Setup(m => m.ShouldProcess(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(() => true);

            this.cmdlet = new RegisterAzureProviderPreviewFeatureCmdlet()
            {
                ProviderFeatureClient = new ProviderFeatureClient
                {
                    FeaturesManagementClient = featureClient.Object
                }
            };
            PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
            mockRuntime = new MockCommandRuntime();
            commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RegisterAzureProviderCmdletTests"/> class.
        /// </summary>
        public RegisterAzureProviderCmdletTests(ITestOutputHelper output)
        {
            this.providerOperationsMock = new Mock <IProvidersOperations>();
            XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
            var resourceManagementClient = new Mock <IResourceManagementClient>();

            resourceManagementClient
            .SetupGet(client => client.Providers)
            .Returns(() => this.providerOperationsMock.Object);

            this.commandRuntimeMock = new Mock <ICommandRuntime>();

            this.commandRuntimeMock
            .Setup(m => m.ShouldProcess(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(() => true);

            this.cmdlet = new RegisterAzureProviderCmdlet()
            {
                ResourceManagerSdkClient = new ResourceManagerSdkClient
                {
                    ResourceManagementClient = resourceManagementClient.Object
                }
            };

            PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
            mockRuntime = new MockCommandRuntime();
            commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GetAzureProviderCmdletTests"/> class.
        /// </summary>
        public GetAzureProviderCmdletTests(ITestOutputHelper output)
        {
            this.providerOperationsMock      = new Mock <IProvidersOperations>();
            this.subscriptionsOperationsMock = new Mock <Internal.Subscriptions.ISubscriptionsOperations>();
            XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
            var resourceManagementClient = new Mock <Microsoft.Azure.Management.ResourceManager.IResourceManagementClient>();
            var subscriptionClient       = new Mock <Internal.Subscriptions.ISubscriptionClient>();

            resourceManagementClient
            .SetupGet(client => client.Providers)
            .Returns(() => this.providerOperationsMock.Object);

            subscriptionClient
            .SetupGet(client => client.Subscriptions)
            .Returns(() => this.subscriptionsOperationsMock.Object);

            this.commandRuntimeMock = new Mock <ICommandRuntime>();
            this.cmdlet             = new GetAzureProviderCmdletTest
            {
                //CommandRuntime = commandRuntimeMock.Object,
                ResourceManagerSdkClient = new ResourceManagerSdkClient(resourceManagementClient.Object),
                SubscriptionSdkClient    = new SubscriptionSdkClient(subscriptionClient.Object)
            };
            PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
            mockRuntime = new MockCommandRuntime();
            commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GetAzureProviderFeatureCmdletTests"/> class.
        /// </summary>
        public GetAzureProviderFeatureCmdletTests(ITestOutputHelper output)
        {
            this.featureOperationsMock = new Mock <IFeaturesOperations>();
            var featureClient = new Mock <IFeatureClient>();

            featureClient
            .SetupGet(client => client.Features)
            .Returns(() => this.featureOperationsMock.Object);

            this.commandRuntimeMock = new Mock <ICommandRuntime>();

            this.cmdlet = new GetAzureProviderFeatureCmdletTest
            {
                //CommandRuntime = commandRuntimeMock.Object,
                ProviderFeatureClient = new ProviderFeatureClient
                {
                    FeaturesManagementClient = featureClient.Object
                }
            };
            PSCmdletExtensions.SetCommandRuntimeMock(cmdlet, commandRuntimeMock.Object);
            mockRuntime = new MockCommandRuntime();
            commandRuntimeMock.Setup(f => f.Host).Returns(mockRuntime.Host);
        }
Beispiel #5
0
        private IEnumerable <CommandInfo> GetModuleCmdlets(string modulePath)
        {
            var getCmdletsCommand = $"(Get-Command -Module (Import-Module '{modulePath}' -PassThru))";

            return(PSCmdletExtensions.RunScript <CommandInfo>(getCmdletsCommand));
        }