public void RemoveAzureBgpPeeringSuccessful() { // Setup string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead"; BgpPeeringAccessType accessType = BgpPeeringAccessType.Private; BgpPeerAddressType peerAddressType = BgpPeerAddressType.All; MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); Mock <ExpressRouteManagementClient> client = InitExpressRouteManagementClient(); var bgpMock = new Mock <IBorderGatewayProtocolPeeringOperations>(); ExpressRouteOperationStatusResponse expected = new ExpressRouteOperationStatusResponse() { Status = ExpressRouteOperationStatus.Successful, HttpStatusCode = HttpStatusCode.OK }; var t = new Task <ExpressRouteOperationStatusResponse>(() => expected); t.Start(); bgpMock.Setup(f => f.RemoveAsync(It.Is <string>(sKey => sKey == serviceKey), It.Is <BgpPeeringAccessType>( y => y == accessType), It.Is <BgpPeerAddressType>(z => z == peerAddressType), It.IsAny <CancellationToken>())) .Returns((string sKey, BgpPeeringAccessType aType, BgpPeerAddressType pType, CancellationToken cancellation) => t); client.SetupGet(f => f.BorderGatewayProtocolPeerings).Returns(bgpMock.Object); RemoveAzureBGPPeeringCommand cmdlet = new RemoveAzureBGPPeeringCommand() { ServiceKey = Guid.Parse(serviceKey), AccessType = accessType, PeerAddressType = BgpPeerAddressType.All, CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; cmdlet.ExecuteCmdlet(); Assert.True(mockCommandRuntime.VerboseStream[0].Contains(serviceKey)); }
/// <summary> /// The Remove Border Gateway Protocol Peering operation deletes an /// existing border gateway protocol peering. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations. /// </param> /// <param name='serviceKey'> /// Required. Service key associated with the border gateway protocol /// peering to be deleted. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <param name='peerAddressType'> /// Required. Whether the BGP Peer Address Type to deleted is IPv4, /// IPv6 or All. /// </param> /// <returns> /// The response body contains the status of the specified asynchronous /// operation, indicating whether it has succeeded, is inprogress, or /// has failed. Note that this status is distinct from the HTTP status /// code returned for the Get Operation Status operation itself. If /// the asynchronous operation succeeded, the response body includes /// the HTTP status code for the successful request. If the /// asynchronous operation failed, the response body includes the HTTP /// status code for the failed request, and also includes error /// information regarding the failure. /// </returns> public static ExpressRouteOperationStatusResponse Remove(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeerAddressType peerAddressType) { return(Task.Factory.StartNew((object s) => { return ((IBorderGatewayProtocolPeeringOperations)s).RemoveAsync(serviceKey, accessType, peerAddressType); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// The Remove Border Gateway Protocol Peering operation deletes an /// existing border gateway protocol peering. /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.ExpressRoute.IBorderGatewayProtocolPeeringOperations. /// </param> /// <param name='serviceKey'> /// Required. Service key associated with the border gateway protocol /// peering to be deleted. /// </param> /// <param name='accessType'> /// Required. Whether the peering is private or public. /// </param> /// <param name='peerAddressType'> /// Required. Whether the BGP Peer Address Type to deleted is IPv4, /// IPv6 or All. /// </param> /// <returns> /// The response body contains the status of the specified asynchronous /// operation, indicating whether it has succeeded, is inprogress, or /// has failed. Note that this status is distinct from the HTTP status /// code returned for the Get Operation Status operation itself. If /// the asynchronous operation succeeded, the response body includes /// the HTTP status code for the successful request. If the /// asynchronous operation failed, the response body includes the HTTP /// status code for the failed request, and also includes error /// information regarding the failure. /// </returns> public static Task <ExpressRouteOperationStatusResponse> RemoveAsync(this IBorderGatewayProtocolPeeringOperations operations, string serviceKey, BgpPeeringAccessType accessType, BgpPeerAddressType peerAddressType) { return(operations.RemoveAsync(serviceKey, accessType, peerAddressType, CancellationToken.None)); }
public bool RemoveAzureBGPPeering(Guid serviceKey, BgpPeeringAccessType accessType, BgpPeerAddressType peerAddressType) { var result = Client.BorderGatewayProtocolPeerings.Remove(serviceKey.ToString(), accessType, peerAddressType); return(result.HttpStatusCode.Equals(HttpStatusCode.OK)); }