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)); }
public void RemoveAzureBgpPeeringSuccessful() { // Setup string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead"; BgpPeeringAccessType accessType = BgpPeeringAccessType.Private; 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.IsAny<CancellationToken>())) .Returns((string sKey, BgpPeeringAccessType aType, CancellationToken cancellation) => t); client.SetupGet(f => f.BorderGatewayProtocolPeerings).Returns(bgpMock.Object); RemoveAzureBGPPeeringCommand cmdlet = new RemoveAzureBGPPeeringCommand() { ServiceKey = serviceKey, AccessType = accessType, CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; cmdlet.ExecuteCmdlet(); Assert.IsTrue(mockCommandRuntime.VerboseStream[0].Contains(serviceKey)); }