Exemplo n.º 1
0
        public void ListAzureDedicatedCircuitLinkSuccessful()
        {
            // Setup


            string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead";

            string vnet1 = "DedicatedCircuitNetwork";
            string vnet2 = "AzureNetwork";

            MockCommandRuntime mockCommandRuntime      = new MockCommandRuntime();
            Mock <ExpressRouteManagementClient> client = InitExpressRouteManagementClient();
            var dclMock = new Mock <IDedicatedCircuitLinkOperations>();

            List <AzureDedicatedCircuitLink> dedicatedCircuitLinks = new List <AzureDedicatedCircuitLink>()
            {
                new AzureDedicatedCircuitLink()
                {
                    VnetName = vnet1, State = DedicatedCircuitLinkState.Provisioned
                },
                new AzureDedicatedCircuitLink()
                {
                    VnetName = vnet2, State = DedicatedCircuitLinkState.NotProvisioned
                }
            };

            DedicatedCircuitLinkListResponse expected =
                new DedicatedCircuitLinkListResponse()
            {
                DedicatedCircuitLinks = dedicatedCircuitLinks,
                StatusCode            = HttpStatusCode.OK
            };

            var t = new Task <DedicatedCircuitLinkListResponse>(() => expected);

            t.Start();

            dclMock.Setup(f => f.ListAsync(It.Is <string>(skey => skey == serviceKey), It.IsAny <CancellationToken>())).Returns((string skey, CancellationToken cancellation) => t);
            client.SetupGet(f => f.DedicatedCircuitLinks).Returns(dclMock.Object);

            GetAzureDedicatedCircuitLinkCommand cmdlet = new GetAzureDedicatedCircuitLinkCommand()
            {
                ServiceKey         = Guid.Parse(serviceKey),
                CommandRuntime     = mockCommandRuntime,
                ExpressRouteClient = new ExpressRouteClient(client.Object)
            };

            cmdlet.ExecuteCmdlet();

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

            Assert.Equal(actual.Count(), 2);
        }
Exemplo n.º 2
0
        public void GetAzureDedicatedCircuitLinkSuccessful()
        {
            // Setup

            string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead";
            string vNetName   = "DedicatedCircuitNetwork";

            MockCommandRuntime mockCommandRuntime      = new MockCommandRuntime();
            Mock <ExpressRouteManagementClient> client = InitExpressRouteManagementClient();
            var dclMock = new Mock <IDedicatedCircuitLinkOperations>();

            DedicatedCircuitLinkGetResponse expected =
                new DedicatedCircuitLinkGetResponse()
            {
                DedicatedCircuitLink = new AzureDedicatedCircuitLink()
                {
                    VnetName = vNetName,
                    State    = DedicatedCircuitLinkState.Provisioned
                },
                RequestId  = "",
                StatusCode = new HttpStatusCode()
            };
            var t = new Task <DedicatedCircuitLinkGetResponse>(() => expected);

            t.Start();

            dclMock.Setup(f => f.GetAsync(It.Is <string>(skey => skey == serviceKey), It.Is <string>(vnet => vnet == vNetName), It.IsAny <CancellationToken>())).Returns((string skey, string vnet, CancellationToken cancellation) => t);
            client.SetupGet(f => f.DedicatedCircuitLinks).Returns(dclMock.Object);

            GetAzureDedicatedCircuitLinkCommand cmdlet = new GetAzureDedicatedCircuitLinkCommand()
            {
                ServiceKey         = Guid.Parse(serviceKey),
                VNetName           = vNetName,
                CommandRuntime     = mockCommandRuntime,
                ExpressRouteClient = new ExpressRouteClient(client.Object)
            };

            cmdlet.ExecuteCmdlet();

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

            Assert.Equal <string>(expected.DedicatedCircuitLink.VnetName, actual.VnetName);
            Assert.Equal(expected.DedicatedCircuitLink.State.ToString(), actual.State.ToString());
        }
        public void GetAzureDedicatedCircuitLinkSuccessful()
        {
            // Setup

            string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead";
            string vNetName = "DedicatedCircuitNetwork";

            MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
            Mock<ExpressRouteManagementClient> client = InitExpressRouteManagementClient();
            var dclMock = new Mock<IDedicatedCircuitLinkOperations>();

            DedicatedCircuitLinkGetResponse expected =
                new DedicatedCircuitLinkGetResponse()
                {
                    DedicatedCircuitLink = new AzureDedicatedCircuitLink()
                    {
                        VnetName = vNetName,
                        State = DedicatedCircuitLinkState.Provisioned
                    },
                    RequestId = "",
                    StatusCode = new HttpStatusCode()
                };
            var t = new Task<DedicatedCircuitLinkGetResponse>(() => expected);
            t.Start();

            dclMock.Setup(f => f.GetAsync(It.Is<string>(skey => skey == serviceKey), It.Is<string>(vnet => vnet == vNetName), It.IsAny<CancellationToken>())).Returns((string skey, string vnet, CancellationToken cancellation) => t);
            client.SetupGet(f => f.DedicatedCircuitLink).Returns(dclMock.Object);

            GetAzureDedicatedCircuitLinkCommand cmdlet = new GetAzureDedicatedCircuitLinkCommand()
            {
                ServiceKey = serviceKey,
                VNetName = vNetName,
                CommandRuntime = mockCommandRuntime,
                ExpressRouteClient = new ExpressRouteClient(client.Object)
            };

            cmdlet.ExecuteCmdlet();

            // Assert
            AzureDedicatedCircuitLink actual = mockCommandRuntime.OutputPipeline[0] as AzureDedicatedCircuitLink;
            Assert.AreEqual<string>(expected.DedicatedCircuitLink.VnetName, actual.VnetName);
            Assert.AreEqual(expected.DedicatedCircuitLink.State.ToString(), actual.State.ToString());

        }
        public void ListAzureDedicatedCircuitLinkSuccessful()
        {
            // Setup

            
            string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead";

            string vnet1 = "DedicatedCircuitNetwork";
            string vnet2 = "AzureNetwork";

            MockCommandRuntime mockCommandRuntime = new MockCommandRuntime();
            Mock<ExpressRouteManagementClient> client = InitExpressRouteManagementClient();
            var dclMock = new Mock<IDedicatedCircuitLinkOperations>();

            List<AzureDedicatedCircuitLink> dedicatedCircuitLinks = new List<AzureDedicatedCircuitLink>(){ 
                new AzureDedicatedCircuitLink(){ VnetName = vnet1, State = DedicatedCircuitLinkState.Provisioned}, 
                new AzureDedicatedCircuitLink(){ VnetName = vnet2, State = DedicatedCircuitLinkState.NotProvisioned}};

            DedicatedCircuitLinkListResponse expected =
                new DedicatedCircuitLinkListResponse()
                {
                    DedicatedCircuitLinks = dedicatedCircuitLinks,
                    StatusCode = HttpStatusCode.OK
                };

            var t = new Task<DedicatedCircuitLinkListResponse>(() => expected);
            t.Start();

            dclMock.Setup(f => f.ListAsync(It.Is<string>(skey => skey == serviceKey), It.IsAny<CancellationToken>())).Returns((string skey, CancellationToken cancellation) => t);
            client.SetupGet(f => f.DedicatedCircuitLink).Returns(dclMock.Object);

            GetAzureDedicatedCircuitLinkCommand cmdlet = new GetAzureDedicatedCircuitLinkCommand()
            {
                ServiceKey = serviceKey,
                CommandRuntime = mockCommandRuntime,
                ExpressRouteClient = new ExpressRouteClient(client.Object)
            };

            cmdlet.ExecuteCmdlet();

            // Assert
            IEnumerable<AzureDedicatedCircuitLink> actual =
                mockCommandRuntime.OutputPipeline[0] as IEnumerable<AzureDedicatedCircuitLink>;
            Assert.AreEqual(actual.ToArray().Count(), 2);
        }