Beispiel #1
0
        public void CreatesNewSBCaseInsensitiveRegion()
        {
            // 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.ToLower(),
                CommandRuntime = mockCommandRuntime,
                Client         = client.Object
            };
            ExtendedServiceBusNamespace expected = new ExtendedServiceBusNamespace {
                Name = name, Region = location
            };

            client.Setup(f => f.CreateNamespace(name, location.ToLower())).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);
        }
Beispiel #2
0
        public void NewAzureSBNamespaceGetsDefaultLocation()
        {
            // Setup
            Mock <ServiceBusClientExtensions> client      = new Mock <ServiceBusClientExtensions>();
            MockCommandRuntime         mockCommandRuntime = new MockCommandRuntime();
            string                     name     = "test";
            string                     location = "West US";
            NewAzureSBNamespaceCommand cmdlet   = new NewAzureSBNamespaceCommand()
            {
                Name           = name,
                CommandRuntime = mockCommandRuntime,
                Client         = client.Object,
                Location       = location
            };
            ExtendedServiceBusNamespace expected = new ExtendedServiceBusNamespace {
                Name = name, Region = location
            };

            client.Setup(f => f.CreateNamespace(name, location)).Returns(expected);

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            ExtendedServiceBusNamespace actual = mockCommandRuntime.OutputPipeline[0] as ExtendedServiceBusNamespace;

            Assert.AreEqual <ExtendedServiceBusNamespace>(expected, actual);
        }
Beispiel #3
0
        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 NewAzureSBNamespaceNoACSSuccessfull()
        {
            // Setup
            MockCommandRuntime mockCommandRuntime    = new MockCommandRuntime();
            Mock <ServiceBusClientExtensions> client = new Mock <ServiceBusClientExtensions>();
            string        name                = "test1";
            string        location            = "West US";
            NamespaceType type                = NamespaceType.NotificationHub;
            NewAzureSBNamespaceCommand cmdlet = new NewAzureSBNamespaceCommand()
            {
                Name               = name,
                Location           = location,
                CreateACSNamespace = false,
                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, false)).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);
        }