public void RemoveAzureDedicatedCircuitLinkSuccessful() { string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead"; string vNetName = "DedicatedCircuitNetwork"; ExpressRouteOperationStatusResponse expected = new ExpressRouteOperationStatusResponse() { Status = ExpressRouteOperationStatus.Successful, HttpStatusCode = HttpStatusCode.OK }; MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); Mock <ExpressRouteManagementClient> client = InitExpressRouteManagementClient(); var dclMock = new Mock <IDedicatedCircuitLinkOperations>(); var t = new Task <ExpressRouteOperationStatusResponse>(() => expected); t.Start(); dclMock.Setup(f => f.RemoveAsync(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); RemoveAzureDedicatedCircuitLinkCommand cmdlet = new RemoveAzureDedicatedCircuitLinkCommand() { ServiceKey = Guid.Parse(serviceKey), VNetName = vNetName, CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; cmdlet.ExecuteCmdlet(); Assert.True(mockCommandRuntime.VerboseStream[0].Contains(serviceKey)); }
public void RemoveAzureDedicatedCircuitSuccessful() { string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead"; string vNetName = "DedicatedCircuitNetwork"; ExpressRouteOperationStatusResponse expected = new ExpressRouteOperationStatusResponse() { Status = ExpressRouteOperationStatus.Successful, HttpStatusCode = HttpStatusCode.OK }; MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); Mock<ExpressRouteManagementClient> client = InitExpressRouteManagementClient(); var dclMock = new Mock<IDedicatedCircuitLinkOperations>(); var t = new Task<ExpressRouteOperationStatusResponse>(() => expected); t.Start(); dclMock.Setup(f => f.RemoveAsync(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); RemoveAzureDedicatedCircuitLinkCommand cmdlet = new RemoveAzureDedicatedCircuitLinkCommand() { ServiceKey = serviceKey, VNetName = vNetName, CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; cmdlet.ExecuteCmdlet(); Assert.IsTrue(mockCommandRuntime.VerboseStream[0].Contains(serviceKey)); }