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);
}