コード例 #1
0
        public void AddVNetsThatDontExist()
        {
            List <TrackingResult> trackingIds = null;
            VNetParameter         vNetDetails = new VNetParameter()
            {
                Region            = region,
                VnetAddressSpaces = new List <string>()
                {
                    "10.0.0.0/16"
                },
                LocalAddressSpaces = new List <string>()
                {
                    "11.0.0.0/16"
                },
                DnsServers = new List <string>()
                {
                    "11.0.0.10"
                },
                VpnAddress  = "13.0.0.1",
                GatewayType = GatewayType.StaticRouting
            };
            int countOfAddedVNets            = 0;
            NewAzureRemoteAppVNet mockCmdlet = SetUpTestCommon <NewAzureRemoteAppVNet>();


            // Required parameters for this test
            mockCmdlet.VNetName = "vNetTest1";
            mockCmdlet.Location = vNetDetails.Region;
            mockCmdlet.VirtualNetworkAddressSpace = vNetDetails.VnetAddressSpaces.ToArray();
            mockCmdlet.LocalNetworkAddressSpace   = vNetDetails.LocalAddressSpaces.ToArray();
            mockCmdlet.DnsServerIpAddress         = vNetDetails.DnsServers.ToArray();
            mockCmdlet.VpnDeviceIpAddress         = vNetDetails.VpnAddress;
            mockCmdlet.GatewayType = vNetDetails.GatewayType;

            // Setup the environment for testing this cmdlet
            countOfAddedVNets = MockObject.SetUpDefaultRemoteAppAddVNet(remoteAppManagementClientMock, vNetDetails);
            mockCmdlet.ResetPipelines();

            Log("Calling Add-AzureRemoteAppVNet which should have {0} VNets", countOfAddedVNets);

            mockCmdlet.ExecuteCmdlet();
            if (mockCmdlet.runTime().ErrorStream.Count != 0)
            {
                Assert.True(false,
                            String.Format("Add-AzureRemoteAppVNet returned the following error {0}",
                                          mockCmdlet.runTime().ErrorStream[0].Exception.Message
                                          )
                            );
            }

            trackingIds = MockObject.ConvertList <TrackingResult>(mockCmdlet.runTime().OutputPipeline);
            Assert.NotNull(trackingIds);

            Assert.True(MockObject.HasExpectedResults <TrackingResult>(trackingIds, MockObject.ContainsExpectedTrackingId),
                        "The actual result does not match the expected."
                        );

            Log("The test for Add-AzureRemoteAppVNet completed successfully");
        }
コード例 #2
0
        public void CanCreateVnet()
        {
            using (UndoContext context = UndoContext.Current)
            {
                context.Start();
                HttpRecorderMode          mode = HttpMockServer.GetCurrentMode();
                RemoteAppManagementClient remoteAppManagementClient = GetRemoteAppManagementClient();

                string        vnetName = "hkutvnet1";
                VNetParameter payload  = new VNetParameter()
                {
                    Region            = "West US",
                    VnetAddressSpaces = new List <string>
                    {
                        "172.16.0.0/16"
                    },
                    LocalAddressSpaces = new List <string>
                    {
                        "11.0.0.0/16"
                    },
                    DnsServers = new List <string>()
                    {
                        "10.0.0.1"
                    },
                    VpnAddress  = "13.0.0.1",
                    GatewayType = GatewayType.StaticRouting
                };

                Assert.DoesNotThrow(() =>
                {
                    OperationResultWithTrackingId result = remoteAppManagementClient.VNet.CreateOrUpdate(vnetName, payload);

                    Assert.NotNull(result);
                    Assert.True(result.StatusCode == HttpStatusCode.OK || result.StatusCode == HttpStatusCode.Accepted, "StatusCode = " + result.StatusCode + "is not one of the expected");

                    if (result.StatusCode == HttpStatusCode.Accepted)
                    {
                        Assert.NotNull(result.TrackingId);
                    }

                    // verify the creation
                    VNetResult vnet = remoteAppManagementClient.VNet.Get(vnetName, false);

                    Assert.NotNull(vnet);
                    Assert.Equal(HttpStatusCode.OK, vnet.StatusCode);
                    Assert.NotNull(vnet.VNet);
                    Assert.Equal(vnetName, vnet.VNet.Name);
                    Assert.Equal(payload.VpnAddress, vnet.VNet.VpnAddress);
                    Assert.Equal(payload.GatewayType, vnet.VNet.GatewayType);
                    Assert.Equal(payload.Region, vnet.VNet.Region);
                });
            }
        }
コード例 #3
0
        public override void ExecuteCmdlet()
        {
            VNetParameter payload = null;
            OperationResultWithTrackingId response = null;

            payload = new VNetParameter()
            {
                VnetAddressSpaces  = new List <string>(VirtualNetworkAddressSpace),
                LocalAddressSpaces = new List <string>(LocalNetworkAddressSpace),
                DnsServers         = new List <string>(DnsServerIpAddress),
                VpnAddress         = VpnDeviceIpAddress,
            };

            response = CallClient(() => Client.VNet.CreateOrUpdate(VNetName, payload), Client.VNet);
            if (response != null)
            {
                WriteTrackingId(response);
            }
        }
コード例 #4
0
        public override void ExecuteCmdlet()
        {
            VNetParameter payload = null;
            OperationResultWithTrackingId response = null;

            payload = new VNetParameter()
            {
                Region             = Location,
                VnetAddressSpaces  = new List <string>(VirtualNetworkAddressSpace),
                LocalAddressSpaces = new List <string>(LocalNetworkAddressSpace),
                DnsServers         = new List <string>(DnsServerIpAddress),
                VpnAddress         = VpnDeviceIpAddress,
                GatewayType        = GatewayType
            };

            RegisterSubscriptionWithRdfeForRemoteApp();

            response = CallClient(() => Client.VNet.CreateOrUpdate(VNetName, payload), Client.VNet);
            if (response != null)
            {
                WriteTrackingId(response);
            }
        }
コード例 #5
0
 /// <summary>
 /// Creates or updates a virtual network.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.RemoteApp.IVNetOperations.
 /// </param>
 /// <param name='vNetName'>
 /// Required. RemoteApp virtual network name.
 /// </param>
 /// <param name='vNetDetails'>
 /// Required. Details about the virtual network to create or update.
 /// </param>
 /// <returns>
 /// The response containing the operation tracking id.
 /// </returns>
 public static Task <OperationResultWithTrackingId> CreateOrUpdateAsync(this IVNetOperations operations, string vNetName, VNetParameter vNetDetails)
 {
     return(operations.CreateOrUpdateAsync(vNetName, vNetDetails, CancellationToken.None));
 }
コード例 #6
0
 /// <summary>
 /// Creates or updates a virtual network.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.RemoteApp.IVNetOperations.
 /// </param>
 /// <param name='vNetName'>
 /// Required. RemoteApp virtual network name.
 /// </param>
 /// <param name='vNetDetails'>
 /// Required. Details about the virtual network to create or update.
 /// </param>
 /// <returns>
 /// The response containing the operation tracking id.
 /// </returns>
 public static OperationResultWithTrackingId CreateOrUpdate(this IVNetOperations operations, string vNetName, VNetParameter vNetDetails)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IVNetOperations)s).CreateOrUpdateAsync(vNetName, vNetDetails);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
コード例 #7
0
        public static int SetUpDefaultRemoteAppAddVNet(Mock <IRemoteAppManagementClient> clientMock, VNetParameter vNetDetails)
        {
            List <VNet> vnetList = new List <VNet>()
            {
                new VNet()
                {
                    Region             = vNetDetails.Region,
                    VnetAddressSpaces  = vNetDetails.VnetAddressSpaces,
                    LocalAddressSpaces = vNetDetails.LocalAddressSpaces,
                    DnsServers         = vNetDetails.DnsServers,
                    VpnAddress         = vNetDetails.VpnAddress,
                    GatewayType        = vNetDetails.GatewayType
                }
            };

            mockVNetList = vnetList;

            OperationResultWithTrackingId response = new OperationResultWithTrackingId()
            {
                StatusCode = System.Net.HttpStatusCode.Accepted,
                TrackingId = "12345",
                RequestId  = "111-2222-4444"
            };

            mockTrackingId = new List <TrackingResult>()
            {
                new TrackingResult(response)
            };

            ISetup <IRemoteAppManagementClient, Task <OperationResultWithTrackingId> > setup =
                clientMock.Setup(c => c.VNet.CreateOrUpdateAsync(It.IsAny <string>(), It.IsAny <VNetParameter>(), It.IsAny <CancellationToken>()));

            setup.Returns(Task.Factory.StartNew(() => response));

            return(mockVNetList.Count);
        }