private bool GetVNetList(bool showAllVirtualNetworks, string VNet) { VNetListResult response = null; bool found = false; if (showAllVirtualNetworks) { WriteVerboseWithTimestamp("Getting all VNets."); } else if (UseWildcard) { WriteVerboseWithTimestamp("Getting the matching VNets for {0}.", VNet); } response = CallClient(() => Client.VNet.List(), Client.VNet); if (response != null) { foreach (VNet vNet in response.VNetList) { if (showAllVirtualNetworks || (UseWildcard && Wildcard.IsMatch(vNet.Name))) { WriteObject(vNet); found = true; } } } return(found); }
public void CanDeleteVnet() { using (UndoContext context = UndoContext.Current) { context.Start(); HttpRecorderMode mode = HttpMockServer.GetCurrentMode(); RemoteAppManagementClient remoteAppManagementClient = GetRemoteAppManagementClient(); VNet vnet = null; // verify the creation VNetListResult vnetList = null; Assert.DoesNotThrow(() => { vnetList = remoteAppManagementClient.VNet.List(); }); Assert.NotNull(vnetList); Assert.Equal(HttpStatusCode.OK, vnetList.StatusCode); Assert.NotNull(vnetList.VNetList); Assert.NotEmpty(vnetList.VNetList); foreach (VNet v in vnetList.VNetList) { if (Regex.IsMatch(v.Name, @"^hkutvnet")) { // found a match if (v.State == VNetState.Connecting || v.State == VNetState.Ready) { vnet = v; break; } } } Assert.NotNull(vnet); OperationResultWithTrackingId deleteResult = remoteAppManagementClient.VNet.Delete(vnet.Name); Assert.NotNull(deleteResult); Assert.True(deleteResult.StatusCode == HttpStatusCode.OK || deleteResult.StatusCode == HttpStatusCode.Accepted, "StatusCode = " + deleteResult.StatusCode + "is not one of the expected"); if (deleteResult.StatusCode == HttpStatusCode.Accepted) { Assert.NotNull(deleteResult.TrackingId); } } }
private string GetVNetName() { if (UseTestVnet) { return(TestVnet); } else { RemoteAppManagementClient remoteAppManagementClient = GetRemoteAppManagementClient(); VNetListResult vnets = remoteAppManagementClient.VNet.List(); Assert.NotNull(vnets); Assert.Equal(HttpStatusCode.OK, vnets.StatusCode); IList <VNet> vnetsList = vnets.VNetList; Random r = new Random(42); int index = r.Next(0, vnetsList.Count - 1); return(vnetsList[index].Name); } }
public void CanGetVnetList() { using (UndoContext context = UndoContext.Current) { context.Start(); HttpRecorderMode mode = HttpMockServer.GetCurrentMode(); RemoteAppManagementClient remoteAppManagementClient = GetRemoteAppManagementClient(); Assert.DoesNotThrow(() => { VNetListResult result = remoteAppManagementClient.VNet.List(); Assert.NotNull(result); Assert.Equal(HttpStatusCode.OK, result.StatusCode); AssertNotNullOrEmpty(result.RequestId); ValidateVnets(result.VNetList); }); } }
public static int SetUpDefaultRemoteAppVNet(Mock <IRemoteAppManagementClient> clientMock, string vNetName) { VNetListResult response = new VNetListResult(); response.VNetList = new List <VNet>() { new VNet() { Name = vNetName, Region = "West US", State = VNetState.Ready }, new VNet() { Name = "test2", Region = "East US", State = VNetState.Provisioning } }; mockVNetList = new List <VNet>(); foreach (VNet vNet in response.VNetList) { VNet mockVNet = new VNet() { Name = vNet.Name, Region = vNet.Region, State = vNet.State }; mockVNetList.Add(mockVNet); } ISetup <IRemoteAppManagementClient, Task <VNetListResult> > setup = clientMock.Setup(c => c.VNet.ListAsync(It.IsAny <CancellationToken>())); setup.Returns(Task.Factory.StartNew(() => response)); return(mockVNetList.Count); }