예제 #1
0
        public void GetAzureSBLocationSuccessfull()
        {
            // Setup
            Mock <ServiceBusClientExtensions> client     = new Mock <ServiceBusClientExtensions>();
            MockCommandRuntime        mockCommandRuntime = new MockCommandRuntime();
            string                    name   = "test";
            GetAzureSBLocationCommand cmdlet = new GetAzureSBLocationCommand()
            {
                CommandRuntime = mockCommandRuntime,
                Client         = client.Object
            };
            List <ServiceBusLocation> expected = new List <ServiceBusLocation>();

            expected.Add(new ServiceBusLocation {
                Code = name, FullName = name
            });
            client.Setup(f => f.GetServiceBusRegions()).Returns(expected);

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            IEnumerable <ServiceBusLocation> actual =
                System.Management.Automation.LanguagePrimitives.GetEnumerable(mockCommandRuntime.OutputPipeline).Cast <ServiceBusLocation>();

            Assert.Equal <int>(expected.Count, actual.Count());

            for (int i = 0; i < expected.Count; i++)
            {
                Assert.True(actual.Any((account) => account.Code == expected[i].Code));
                Assert.True(actual.Any((account) => account.FullName == expected[i].FullName));
            }
        }
        public void GetAzureSBLocationSuccessfull()
        {
            // Setup
            Mock <ServiceBusClientExtensions> client     = new Mock <ServiceBusClientExtensions>();
            MockCommandRuntime        mockCommandRuntime = new MockCommandRuntime();
            string                    name   = "test";
            GetAzureSBLocationCommand cmdlet = new GetAzureSBLocationCommand()
            {
                CommandRuntime = mockCommandRuntime,
                Client         = client.Object
            };
            List <ServiceBusLocation> expected = new List <ServiceBusLocation>();

            expected.Add(new ServiceBusLocation {
                Code = name, FullName = name
            });
            client.Setup(f => f.GetServiceBusRegions()).Returns(expected);

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            List <ServiceBusLocation> actual = mockCommandRuntime.OutputPipeline[0] as List <ServiceBusLocation>;

            Assert.AreEqual <int>(expected.Count, actual.Count);

            for (int i = 0; i < expected.Count; i++)
            {
                Assert.AreEqual <string>(expected[i].Code, actual[i].Code);
                Assert.AreEqual <string>(expected[i].FullName, actual[i].FullName);
            }
        }
        public void GetAzureSBLocationSuccessfull()
        {
            // Setup
            Mock<ServiceBusClientExtensions> client = new Mock<ServiceBusClientExtensions>();
            MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
            string name = "test";
            GetAzureSBLocationCommand cmdlet = new GetAzureSBLocationCommand()
            {
                CommandRuntime = mockCommandRuntime,
                Client = client.Object
            };
            List<ServiceBusLocation> expected = new List<ServiceBusLocation>();
            expected.Add(new ServiceBusLocation { Code = name, FullName = name });
            client.Setup(f => f.GetServiceBusRegions()).Returns(expected);

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            List<ServiceBusLocation> actual = mockCommandRuntime.OutputPipeline[0] as List<ServiceBusLocation>;
            Assert.AreEqual<int>(expected.Count, actual.Count);

            for (int i = 0; i < expected.Count; i++)
            {
                Assert.AreEqual<string>(expected[i].Code, actual[i].Code);
                Assert.AreEqual<string>(expected[i].FullName, actual[i].FullName);
            }
        }
예제 #4
0
        public void GetAzureSBLocationSuccessfull()
        {
            // Setup
            SimpleServiceBusManagement channel            = new SimpleServiceBusManagement();
            MockCommandRuntime         mockCommandRuntime = new MockCommandRuntime();
            string name = "test";
            GetAzureSBLocationCommand cmdlet = new GetAzureSBLocationCommand(channel)
            {
                CommandRuntime = mockCommandRuntime
            };
            List <ServiceBusRegion> expected = new List <ServiceBusRegion>();

            expected.Add(new ServiceBusRegion {
                Code = name, FullName = name
            });
            channel.ListServiceBusRegionsThunk = gn => { return(expected); };

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            List <ServiceBusRegion> actual = mockCommandRuntime.OutputPipeline[0] as List <ServiceBusRegion>;

            Assert.AreEqual <int>(expected.Count, actual.Count);

            for (int i = 0; i < expected.Count; i++)
            {
                Assert.AreEqual <string>(expected[i].Code, actual[i].Code);
                Assert.AreEqual <string>(expected[i].FullName, actual[i].FullName);
            }
        }
        public void GetAzureSBLocationSuccessfull()
        {
            // Setup
            SimpleServiceBusManagement channel = new SimpleServiceBusManagement();
            MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
            string name = "test";
            GetAzureSBLocationCommand cmdlet = new GetAzureSBLocationCommand(channel) { CommandRuntime = mockCommandRuntime };
            List<ServiceBusRegion> expected = new List<ServiceBusRegion>();
            expected.Add(new ServiceBusRegion { Code = name, FullName = name });
            channel.ListServiceBusRegionsThunk = gn => { return expected; };

            // Test
            cmdlet.ExecuteCmdlet();

            // Assert
            List<ServiceBusRegion> actual = mockCommandRuntime.OutputPipeline[0] as List<ServiceBusRegion>;
            Assert.AreEqual<int>(expected.Count, actual.Count);

            for (int i = 0; i < expected.Count; i++)
            {
                Assert.AreEqual<string>(expected[i].Code, actual[i].Code);
                Assert.AreEqual<string>(expected[i].FullName, actual[i].FullName);
            }
        }