public void ListAzureDedicatedCircuitSuccessful() { // Setup string circuitName1 = "TestCircuit"; uint bandwidth1 = 10; string serviceProviderName1 = "TestProvider"; string location1 = "us-west"; string serviceKey1 = "aa28cd19-b10a-41ff-981b-53c6bbf15ead"; string circuitName2 = "TestCircuit2"; uint bandwidth2 = 10; string serviceProviderName2 = "TestProvider"; string location2 = "us-north"; string serviceKey2 = "bc28cd19-b10a-41ff-981b-53c6bbf15ead"; MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); Mock <ExpressRouteManagementClient> client = InitExpressRouteManagementClient(); var dcMock = new Mock <IDedicatedCircuitOperations>(); List <AzureDedicatedCircuit> dedicatedCircuits = new List <AzureDedicatedCircuit>() { new AzureDedicatedCircuit() { Bandwidth = bandwidth1, CircuitName = circuitName1, ServiceKey = serviceKey1, Location = location1, ServiceProviderName = serviceProviderName1, ServiceProviderProvisioningState = ProviderProvisioningState.NotProvisioned, Status = DedicatedCircuitState.Enabled }, new AzureDedicatedCircuit() { Bandwidth = bandwidth2, CircuitName = circuitName2, ServiceKey = serviceKey2, Location = location2, ServiceProviderName = serviceProviderName2, ServiceProviderProvisioningState = ProviderProvisioningState.Provisioned, Status = DedicatedCircuitState.Enabled } }; DedicatedCircuitListResponse expected = new DedicatedCircuitListResponse() { DedicatedCircuits = dedicatedCircuits, StatusCode = HttpStatusCode.OK }; var t = new Task <DedicatedCircuitListResponse>(() => expected); t.Start(); dcMock.Setup(f => f.ListAsync(It.IsAny <CancellationToken>())).Returns((CancellationToken cancellation) => t); client.SetupGet(f => f.DedicatedCircuits).Returns(dcMock.Object); GetAzureDedicatedCircuitCommand cmdlet = new GetAzureDedicatedCircuitCommand() { CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; cmdlet.ExecuteCmdlet(); // Assert IEnumerable <AzureDedicatedCircuit> actual = mockCommandRuntime.OutputPipeline[0] as IEnumerable <AzureDedicatedCircuit>; Assert.Equal(actual.ToArray().Count(), 2); }
public void GetAzureDedicatedCircuitSuccessful() { // Setup string circuitName = "TestCircuit"; uint bandwidth = 10; string serviceProviderName = "TestProvider"; string location = "us-west"; string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead"; BillingType billingType = BillingType.MeteredData; MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); Mock <ExpressRouteManagementClient> client = InitExpressRouteManagementClient(); var dcMock = new Mock <IDedicatedCircuitOperations>(); DedicatedCircuitGetResponse expected = new DedicatedCircuitGetResponse() { DedicatedCircuit = new AzureDedicatedCircuit() { CircuitName = circuitName, Bandwidth = bandwidth, BillingType = billingType.ToString(), Location = location, ServiceProviderName = serviceProviderName, ServiceKey = serviceKey, ServiceProviderProvisioningState = ProviderProvisioningState.NotProvisioned, Status = DedicatedCircuitState.Enabled, }, RequestId = "", StatusCode = new HttpStatusCode() }; var t = new Task <DedicatedCircuitGetResponse>(() => expected); t.Start(); dcMock.Setup(f => f.GetAsync(It.Is <string>(sKey => sKey == serviceKey), It.IsAny <CancellationToken>())).Returns((string sKey, CancellationToken cancellation) => t); client.SetupGet(f => f.DedicatedCircuits).Returns(dcMock.Object); GetAzureDedicatedCircuitCommand cmdlet = new GetAzureDedicatedCircuitCommand() { ServiceKey = Guid.Parse(serviceKey), CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; cmdlet.ExecuteCmdlet(); // Assert AzureDedicatedCircuit actual = mockCommandRuntime.OutputPipeline[0] as AzureDedicatedCircuit; Assert.Equal <string>(expected.DedicatedCircuit.BillingType, actual.BillingType); Assert.Equal <string>(expected.DedicatedCircuit.CircuitName, actual.CircuitName); Assert.Equal <uint>(expected.DedicatedCircuit.Bandwidth, actual.Bandwidth); Assert.Equal <string>(expected.DedicatedCircuit.Location, actual.Location); Assert.Equal <string>(expected.DedicatedCircuit.ServiceProviderName, actual.ServiceProviderName); Assert.Equal(expected.DedicatedCircuit.ServiceProviderProvisioningState, actual.ServiceProviderProvisioningState); Assert.Equal(expected.DedicatedCircuit.Status, actual.Status); Assert.Equal <string>(expected.DedicatedCircuit.ServiceKey, actual.ServiceKey); }
public void ListAzureDedicatedCircuitSuccessful() { // Setup string circuitName1 = "TestCircuit"; uint bandwidth1 = 10; string serviceProviderName1 = "TestProvider"; string location1 = "us-west"; string serviceKey1 = "aa28cd19-b10a-41ff-981b-53c6bbf15ead"; string circuitName2 = "TestCircuit2"; uint bandwidth2 = 10; string serviceProviderName2 = "TestProvider"; string location2 = "us-north"; string serviceKey2 = "bc28cd19-b10a-41ff-981b-53c6bbf15ead"; MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); Mock<ExpressRouteManagementClient> client = InitExpressRouteManagementClient(); var dcMock = new Mock<IDedicatedCircuitOperations>(); List<AzureDedicatedCircuit> dedicatedCircuits = new List<AzureDedicatedCircuit>(){ new AzureDedicatedCircuit(){ Bandwidth = bandwidth1, CircuitName = circuitName1, ServiceKey = serviceKey1, Location = location1, ServiceProviderName = serviceProviderName1, ServiceProviderProvisioningState = ProviderProvisioningState.NotProvisioned, Status = DedicatedCircuitState.Enabled}, new AzureDedicatedCircuit(){ Bandwidth = bandwidth2, CircuitName = circuitName2, ServiceKey = serviceKey2, Location = location2, ServiceProviderName = serviceProviderName2, ServiceProviderProvisioningState = ProviderProvisioningState.Provisioned, Status = DedicatedCircuitState.Enabled} }; DedicatedCircuitListResponse expected = new DedicatedCircuitListResponse() { DedicatedCircuits = dedicatedCircuits, StatusCode = HttpStatusCode.OK }; var t = new Task<DedicatedCircuitListResponse>(() => expected); t.Start(); dcMock.Setup(f => f.ListAsync(It.IsAny<CancellationToken>())).Returns((CancellationToken cancellation) => t); client.SetupGet(f => f.DedicatedCircuit).Returns(dcMock.Object); GetAzureDedicatedCircuitCommand cmdlet = new GetAzureDedicatedCircuitCommand() { CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; cmdlet.ExecuteCmdlet(); // Assert IEnumerable<AzureDedicatedCircuit> actual = mockCommandRuntime.OutputPipeline[0] as IEnumerable<AzureDedicatedCircuit>; Assert.AreEqual(actual.ToArray().Count(), 2); }
public void GetAzureDedicatedCircuitSuccessful() { // Setup string circuitName = "TestCircuit"; uint bandwidth = 10; string serviceProviderName = "TestProvider"; string location = "us-west"; string serviceKey = "aa28cd19-b10a-41ff-981b-53c6bbf15ead"; MockCommandRuntime mockCommandRuntime = new MockCommandRuntime(); Mock<ExpressRouteManagementClient> client = InitExpressRouteManagementClient(); var dcMock = new Mock<IDedicatedCircuitOperations>(); DedicatedCircuitGetResponse expected = new DedicatedCircuitGetResponse() { DedicatedCircuit = new AzureDedicatedCircuit() { CircuitName = circuitName, Bandwidth = bandwidth, Location = location, ServiceProviderName = serviceProviderName, ServiceKey = serviceKey, ServiceProviderProvisioningState = ProviderProvisioningState.NotProvisioned, Status = DedicatedCircuitState.Enabled, }, RequestId = "", StatusCode = new HttpStatusCode() }; var t = new Task<DedicatedCircuitGetResponse>(() => expected); t.Start(); dcMock.Setup(f => f.GetAsync(It.Is<string>(sKey => sKey == serviceKey), It.IsAny<CancellationToken>())).Returns((string sKey, CancellationToken cancellation) => t); client.SetupGet(f => f.DedicatedCircuit).Returns(dcMock.Object); GetAzureDedicatedCircuitCommand cmdlet = new GetAzureDedicatedCircuitCommand() { ServiceKey = serviceKey, CommandRuntime = mockCommandRuntime, ExpressRouteClient = new ExpressRouteClient(client.Object) }; cmdlet.ExecuteCmdlet(); // Assert AzureDedicatedCircuit actual = mockCommandRuntime.OutputPipeline[0] as AzureDedicatedCircuit; Assert.AreEqual<string>(expected.DedicatedCircuit.CircuitName, actual.CircuitName); Assert.AreEqual<uint>(expected.DedicatedCircuit.Bandwidth, actual.Bandwidth); Assert.AreEqual<string>(expected.DedicatedCircuit.Location, actual.Location); Assert.AreEqual<string>(expected.DedicatedCircuit.ServiceProviderName, actual.ServiceProviderName); Assert.AreEqual(expected.DedicatedCircuit.ServiceProviderProvisioningState, actual.ServiceProviderProvisioningState); Assert.AreEqual(expected.DedicatedCircuit.Status, actual.Status); Assert.AreEqual<string>(expected.DedicatedCircuit.ServiceKey, actual.ServiceKey); }