public void RemoveAzureSBNamespaceSuccessfull() { // Setup SimpleServiceBusManagement channel = new SimpleServiceBusManagement(); MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); string name = "test"; RemoveAzureSBNamespaceCommand cmdlet = new RemoveAzureSBNamespaceCommand(channel) { Name = name, CommandRuntime = mockCommandRuntime, PassThru = true }; bool deleted = false; channel.DeleteServiceBusNamespaceThunk = dsbn => { deleted = true; }; // Test cmdlet.ExecuteCmdlet(); // Assert Assert.IsTrue(deleted); Assert.IsTrue((bool)mockCommandRuntime.OutputPipeline[0]); }
public void RemoveAzureSBNamespaceWithInternalServerError() { // Setup SimpleServiceManagement channel = new SimpleServiceManagement(); FakeWriter writer = new FakeWriter(); string name = "test"; RemoveAzureSBNamespaceCommand cmdlet = new RemoveAzureSBNamespaceCommand(channel) { Name = name, Writer = writer }; string expected = Resources.RemoveNamespaceErrorMessage; channel.DeleteServiceBusNamespaceThunk = dsbn => { throw new Exception(Resources.InternalServerErrorMessage); }; // Test cmdlet.ExecuteCmdlet(); // Assert ErrorRecord actual = writer.ErrorChannel[0]; Assert.AreEqual<string>(expected, actual.Exception.Message); }
public void RemoveAzureSBNamespaceWithInvalidNamesFail() { // Setup string[] invalidNames = { "1test", "test#", "test invaid", "-test", "_test" }; foreach (string invalidName in invalidNames) { FakeWriter writer = new FakeWriter(); RemoveAzureSBNamespaceCommand cmdlet = new RemoveAzureSBNamespaceCommand() { Name = invalidName, Writer = writer }; ArgumentException expected = new ArgumentException(string.Format(Resources.InvalidNamespaceName, invalidName), "Name"); // Test cmdlet.ExecuteCmdlet(); // Assert ErrorRecord actual = writer.ErrorChannel[0]; Assert.AreEqual<string>(expected.Message, actual.Exception.Message); } }
public void RemoveAzureSBNamespaceSuccessfull() { // Setup SimpleServiceManagement channel = new SimpleServiceManagement(); FakeWriter writer = new FakeWriter(); string name = "test"; RemoveAzureSBNamespaceCommand cmdlet = new RemoveAzureSBNamespaceCommand(channel) { Name = name, Writer = writer }; bool deleted = false; string expectedVerbose = string.Format(Resources.RemovingNamespaceMessage, name); channel.DeleteServiceBusNamespaceThunk = dsbn => { deleted = true; }; // Test cmdlet.ExecuteCmdlet(); // Assert string actual = writer.VerboseChannel[0] as string; Assert.IsTrue(deleted); Assert.AreEqual<string>(expectedVerbose, actual); }
public void RemoveAzureSBNamespaceSuccessfull() { // Setup SimpleServiceBusManagement channel = new SimpleServiceBusManagement(); MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); string name = "test"; RemoveAzureSBNamespaceCommand cmdlet = new RemoveAzureSBNamespaceCommand(channel) { Name = name, CommandRuntime = mockCommandRuntime, PassThru = true }; bool deleted = false; channel.DeleteServiceBusNamespaceThunk = dsbn => { deleted = true; }; // Test cmdlet.ExecuteCmdlet(); // Assert Assert.IsTrue(deleted); Assert.IsTrue((bool)mockCommandRuntime.OutputPipeline[0]); }
public void RemoveAzureSBNamespaceWithInternalServerError() { // Setup SimpleServiceBusManagement channel = new SimpleServiceBusManagement(); MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); string name = "test"; RemoveAzureSBNamespaceCommand cmdlet = new RemoveAzureSBNamespaceCommand(channel) { Name = name, CommandRuntime = mockCommandRuntime }; string expected = Resources.RemoveNamespaceErrorMessage; channel.DeleteServiceBusNamespaceThunk = dsbn => { throw new Exception(Resources.InternalServerErrorMessage); }; // Test cmdlet.ExecuteCmdlet(); // Assert ErrorRecord actual = mockCommandRuntime.ErrorStream[0]; Assert.AreEqual <string>(expected, actual.Exception.Message); }
public void RemoveAzureSBNamespaceWithInvalidNamesFail() { // Setup string[] invalidNames = { "1test", "test#", "test invaid", "-test", "_test" }; foreach (string invalidName in invalidNames) { MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); RemoveAzureSBNamespaceCommand cmdlet = new RemoveAzureSBNamespaceCommand() { Name = invalidName, CommandRuntime = mockCommandRuntime }; ArgumentException expected = new ArgumentException(string.Format(Resources.InvalidNamespaceName, invalidName), "Name"); // Test cmdlet.ExecuteCmdlet(); // Assert ErrorRecord actual = mockCommandRuntime.ErrorStream[0]; Assert.AreEqual <string>(expected.Message, actual.Exception.Message); } }
public void RemoveAzureSBNamespaceSuccessfull() { // Setup Mock<ServiceBusClientExtensions> client = new Mock<ServiceBusClientExtensions>(); MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); string name = "test"; RemoveAzureSBNamespaceCommand cmdlet = new RemoveAzureSBNamespaceCommand() { Name = name, CommandRuntime = mockCommandRuntime, PassThru = true, Client = client.Object }; bool deleted = false; client.Setup(f => f.RemoveNamespace(name)).Callback(() => deleted = true); // Test cmdlet.ExecuteCmdlet(); // Assert Assert.IsTrue(deleted); Assert.IsTrue((bool)mockCommandRuntime.OutputPipeline[0]); }
public void RemoveAzureSBNamespaceSuccessfull() { // Setup Mock <ServiceBusClientExtensions> client = new Mock <ServiceBusClientExtensions>(); MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); string name = "test"; RemoveAzureSBNamespaceCommand cmdlet = new RemoveAzureSBNamespaceCommand() { Name = name, CommandRuntime = mockCommandRuntime, PassThru = true, Client = client.Object }; bool deleted = false; client.Setup(f => f.RemoveNamespace(name)).Callback(() => deleted = true); // Test cmdlet.ExecuteCmdlet(); // Assert Assert.IsTrue(deleted); Assert.IsTrue((bool)mockCommandRuntime.OutputPipeline[0]); }