public void NewAzureDedicatedCircuitLinkSuccessful() { // Setup string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead"; string vNetName = "DedicatedCircuitNetwork"; MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); Mock <ExpressRouteManagementClient> client = InitExpressRouteManagementClient(); var dclMock = new Mock <IDedicatedCircuitLinkOperations>(); DedicatedCircuitLinkGetResponse expected = new DedicatedCircuitLinkGetResponse() { DedicatedCircuitLink = new AzureDedicatedCircuitLink() { VnetName = vNetName, State = DedicatedCircuitLinkState.Provisioned }, RequestId = "", StatusCode = new HttpStatusCode() }; var tGet = new Task <DedicatedCircuitLinkGetResponse>(() => expected); tGet.Start(); ExpressRouteOperationStatusResponse expectedStatus = new ExpressRouteOperationStatusResponse() { HttpStatusCode = HttpStatusCode.OK }; var tNew = new Task <ExpressRouteOperationStatusResponse>(() => expectedStatus); tNew.Start(); dclMock.Setup(f => f.NewAsync(It.Is <string>(x => x == serviceKey), It.Is <string>(y => y == vNetName), It.IsAny <CancellationToken>())).Returns((string sKey, string vNet, CancellationToken cancellation) => tNew); dclMock.Setup(f => f.GetAsync(It.Is <string>(skey => skey == serviceKey), It.Is <string>(vnet => vnet == vNetName), It.IsAny <CancellationToken>())).Returns((string skey, string vnet, CancellationToken cancellation) => tGet); client.SetupGet(f => f.DedicatedCircuitLinks).Returns(dclMock.Object); NewAzureDedicatedCircuitLinkCommand cmdlet = new NewAzureDedicatedCircuitLinkCommand() { ServiceKey = Guid.Parse(serviceKey), VNetName = vNetName, CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; cmdlet.ExecuteCmdlet(); // Assert AzureDedicatedCircuitLink actual = mockCommandRuntime.OutputPipeline[0] as AzureDedicatedCircuitLink; Assert.Equal <string>(expected.DedicatedCircuitLink.VnetName, actual.VnetName); Assert.Equal(expected.DedicatedCircuitLink.State.ToString(), actual.State.ToString()); }
public void NewAzureDedicatedCircuitLinkSuccessful() { // Setup string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead"; string vNetName = "DedicatedCircuitNetwork"; MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); Mock<ExpressRouteManagementClient> client = InitExpressRouteManagementClient(); var dclMock = new Mock<IDedicatedCircuitLinkOperations>(); DedicatedCircuitLinkGetResponse expected = new DedicatedCircuitLinkGetResponse() { DedicatedCircuitLink = new AzureDedicatedCircuitLink() { VnetName = vNetName, State = DedicatedCircuitLinkState.Provisioned }, RequestId = "", StatusCode = new HttpStatusCode() }; var t = new Task<DedicatedCircuitLinkGetResponse>(() => expected); t.Start(); dclMock.Setup(f => f.NewAsync(It.Is<string>(x => x == serviceKey), It.Is<string>(y => y == vNetName), It.IsAny<CancellationToken>())).Returns((string sKey, string vNet, CancellationToken cancellation) => t); client.SetupGet(f => f.DedicatedCircuitLink).Returns(dclMock.Object); NewAzureDedicatedCircuitLinkCommand cmdlet = new NewAzureDedicatedCircuitLinkCommand() { ServiceKey = serviceKey, VNetName = vNetName, CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; cmdlet.ExecuteCmdlet(); // Assert AzureDedicatedCircuitLink actual = mockCommandRuntime.OutputPipeline[0] as AzureDedicatedCircuitLink; Assert.AreEqual<string>(expected.DedicatedCircuitLink.VnetName, actual.VnetName); Assert.AreEqual(expected.DedicatedCircuitLink.State.ToString(), actual.State.ToString()); }