Microsoft.WindowsAzure.Commands.ServiceBus.NewAzureSBNamespaceCommand.ExecuteCmdlet C# (CSharp) Method

ExecuteCmdlet() public method

Creates a new service bus namespace.
public ExecuteCmdlet ( ) : void
return void
        public override void ExecuteCmdlet()
        {
            Client = Client ?? new ServiceBusClientExtensions(Profile);
            if (CreateACSNamespace.HasValue)
            {
                WriteObject(Client.CreateNamespace(Name, Location, NamespaceType, CreateACSNamespace.Value));
            }
            else
            {
                WriteWarning(Resources.SpecifyCreateACSNamespace);
                WriteObject(Client.CreateNamespace(Name, Location, NamespaceType, true));
            }
        }
    }

Usage Example

        public void NewAzureSBNamespaceSuccessfull()
        {
            // Setup
            MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
            Mock<ServiceBusClientExtensions> client = new Mock<ServiceBusClientExtensions>();
            string name = "test";
            string location = "West US";
            NamespaceType type = NamespaceType.Messaging;
            NewAzureSBNamespaceCommand cmdlet = new NewAzureSBNamespaceCommand()
            {
                Name = name,
                Location = location,
                NamespaceType = type,
                CommandRuntime = mockCommandRuntime,
                Client = client.Object
            };
            ExtendedServiceBusNamespace expected = new ExtendedServiceBusNamespace { Name = name, Region = location, NamespaceType = type};
            client.Setup(f => f.CreateNamespace(name, location, type, true)).Returns(expected);
            client.Setup(f => f.GetServiceBusRegions()).Returns(new List<ServiceBusLocation>()
            {
                new ServiceBusLocation () { Code = location }
            });

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            ExtendedServiceBusNamespace actual = mockCommandRuntime.OutputPipeline[0] as ExtendedServiceBusNamespace;
            Assert.Equal<ExtendedServiceBusNamespace>(expected, actual);
        }
All Usage Examples Of Microsoft.WindowsAzure.Commands.ServiceBus.NewAzureSBNamespaceCommand::ExecuteCmdlet
NewAzureSBNamespaceCommand