public void NewAzureSBNamespaceSuccessfull()
        {
            // Setup
            MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
            Mock<ServiceBusClientExtensions> client = new Mock<ServiceBusClientExtensions>();
            string name = "test";
            string location = "West US";
            NewAzureSBNamespaceCommand cmdlet = new NewAzureSBNamespaceCommand()
            {
                Name = name,
                Location = location,
                CommandRuntime = mockCommandRuntime,
                Client = client.Object
            };
            ExtendedServiceBusNamespace expected = new ExtendedServiceBusNamespace { Name = name, Region = location };
            client.Setup(f => f.CreateNamespace(name, location)).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.AreEqual<ExtendedServiceBusNamespace>(expected, actual);
        }
示例#2
0
        public override bool Equals(object obj)
        {
            ExtendedServiceBusNamespace lhs = obj as ExtendedServiceBusNamespace;

            if (string.IsNullOrEmpty(Name))
            {
                return(false);
            }

            return(this.Name.Equals(lhs.Name) && this.Region.Equals(lhs.Region));
        }
        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.AreEqual<string>(expected.Name, actual.Name);
        }
        public void CreatesNewSBCaseInsensitiveRegion()
        {
            // 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.ToLower(),
                CommandRuntime = mockCommandRuntime,
                Client = client.Object
            };
            ExtendedServiceBusNamespace expected = new ExtendedServiceBusNamespace { Name = name, Region = location, NamespaceType = NamespaceType.Messaging};
            client.Setup(f => f.CreateNamespace(name, location.ToLower(), 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);
        }
        public void NewAzureSBNamespaceGetsDefaultLocation()
        {
            // Setup
            Mock<ServiceBusClientExtensions> client = new Mock<ServiceBusClientExtensions>();
            MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
            string name = "test";
            string location = "West US";
            NamespaceType type = NamespaceType.NotificationHub;
            NewAzureSBNamespaceCommand cmdlet = new NewAzureSBNamespaceCommand()
            {
                Name = name,
                CommandRuntime = mockCommandRuntime,
                NamespaceType = type,
                Client = client.Object,
                Location = location
            };
            ExtendedServiceBusNamespace expected = new ExtendedServiceBusNamespace { Name = name, Region = location, NamespaceType = type};
            client.Setup(f => f.CreateNamespace(name, location, type, true)).Returns(expected);

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            ExtendedServiceBusNamespace actual = mockCommandRuntime.OutputPipeline[0] as ExtendedServiceBusNamespace;
            Assert.Equal<ExtendedServiceBusNamespace>(expected, actual);
        }