public void GetAzureSBNamespaceSuccessfull() { // Setup string name = "test"; cmdlet.Name = name; ExtendedServiceBusNamespace expected = new ExtendedServiceBusNamespace { Name = name }; client.Setup(f => f.GetNamespace(name)).Returns(expected); // Test cmdlet.ExecuteCmdlet(); // Assert ExtendedServiceBusNamespace actual = mockCommandRuntime.OutputPipeline[0] as ExtendedServiceBusNamespace; Assert.Equal <string>(expected.Name, actual.Name); }
public void GetAzureSBNamespaceSuccessfull() { // Setup string name = "test"; cmdlet.Name = name; ServiceBusNamespace expected = new ServiceBusNamespace { Name = name }; channel.GetNamespaceThunk = gn => { return(expected); }; // Test cmdlet.ExecuteCmdlet(); // Assert ServiceBusNamespace actual = mockCommandRuntime.OutputPipeline[0] as ServiceBusNamespace; Assert.AreEqual <string>(expected.Name, actual.Name); }
public void GetAzureSBNamespaceWithInvalidNamesFail() { // Setup string[] invalidNames = { "1test", "test#", "test invaid", "-test", "_test" }; foreach (string invalidName in invalidNames) { MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); GetAzureSBNamespaceCommand cmdlet = new GetAzureSBNamespaceCommand() { Name = invalidName, CommandRuntime = mockCommandRuntime }; string expected = string.Format("{0}\r\nParameter name: Name", string.Format(Resources.InvalidNamespaceName, invalidName)); Testing.AssertThrows<ArgumentException>(() => cmdlet.ExecuteCmdlet(), expected); } }
public void GetAzureSBNamespaceWithInvalidNamesFail() { // Setup string[] invalidNames = { "1test", "test#", "test invaid", "-test", "_test" }; foreach (string invalidName in invalidNames) { MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); GetAzureSBNamespaceCommand cmdlet = new GetAzureSBNamespaceCommand() { Name = invalidName, CommandRuntime = mockCommandRuntime }; string expected = string.Format("{0}\r\nParameter name: Name", string.Format(Resources.InvalidNamespaceName, invalidName)); Testing.AssertThrows <ArgumentException>(() => cmdlet.ExecuteCmdlet(), expected); } }
public void GetAzureSBNamespaceWithInvalidNamesFail() { // Setup string[] invalidNames = { "1test", "test#", "test invaid", "-test", "_test" }; Mock <ServiceBusClientExtensions> client = new Mock <ServiceBusClientExtensions>(); foreach (string invalidName in invalidNames) { MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); GetAzureSBNamespaceCommand cmdlet = new GetAzureSBNamespaceCommand() { Name = invalidName, CommandRuntime = mockCommandRuntime, Client = client.Object }; string expected = string.Format("{0}\r\nParameter name: Name", string.Format(Resources.InvalidNamespaceName, invalidName)); client.Setup(f => f.GetNamespace(invalidName)).Throws(new InvalidOperationException(expected)); Testing.AssertThrows <InvalidOperationException>(() => cmdlet.ExecuteCmdlet(), expected); } }