public void ShouldReturnOneStaticIPAddressPool() { var mockChannel = new MockRequestChannel(); var staticIPAddressPoolToCreate = new StaticIPAddressPool() { Name = staticIPAddressPoolName, VMSubnetId = Guid.Empty, IPAddressRangeStart = ipAddressRangeStart, IPAddressRangeEnd = ipAddressRangeEnd, StampId = Guid.Empty }; mockChannel.AddReturnObject(staticIPAddressPoolToCreate); var staticIPAddressPoolOperations = new StaticIPAddressPoolOperations(new WebClientFactory(new Subscription(), mockChannel)); var readStaticIPAddressPool = staticIPAddressPoolOperations.Read(new VMSubnet() { StampId = Guid.Empty, ID = Guid.Empty }); Assert.AreEqual(1, readStaticIPAddressPool.Count); // Check the URI var requestList = mockChannel.ClientRequests; Assert.AreEqual(1, requestList.Count); Assert.AreEqual(baseURI, mockChannel.ClientRequests[0].Item1.Address.AbsolutePath.Substring(1)); }
public override void ExecuteCmdlet() { var staticIPAddressPool = new StaticIPAddressPool() { Name = this.Name, VMSubnetId = this.VMSubnet.ID, Subnet = this.VMSubnet.Subnet, IPAddressRangeStart = this.IPAddressRangeStart, IPAddressRangeEnd = this.IPAddressRangeEnd, StampId = this.VMSubnet.StampId }; Guid?jobId = Guid.Empty; var staticIPAddressPoolOperations = new StaticIPAddressPoolOperations(this.WebClientFactory); var createdStaticIPAddressPool = staticIPAddressPoolOperations.Create(staticIPAddressPool, out jobId); WaitForJobCompletion(jobId); var filter = new Dictionary <string, string> { { "ID", createdStaticIPAddressPool.ID.ToString() }, { "StampId ", createdStaticIPAddressPool.StampId.ToString() } }; var results = staticIPAddressPoolOperations.Read(filter); this.GenerateCmdletOutput(results); }
public void ShouldDeleteStaticIPAddressPool() { var mockChannel = new MockRequestChannel(); var existingStaticIPAddressPool = new StaticIPAddressPool() { Name = staticIPAddressPoolName, VMSubnetId = Guid.Empty, IPAddressRangeStart = ipAddressRangeStart, IPAddressRangeEnd = ipAddressRangeEnd, StampId = Guid.Empty }; mockChannel.AddReturnObject(new Cloud() { StampId = Guid.NewGuid() }); mockChannel.AddReturnObject(existingStaticIPAddressPool, new WebHeaderCollection { "x-ms-request-id:" + Guid.NewGuid() }); Guid?jobOut; var staticIPAddressPoolOperations = new StaticIPAddressPoolOperations(new WebClientFactory(new Subscription(), mockChannel)); staticIPAddressPoolOperations.Delete(Guid.Empty, out jobOut); Assert.AreEqual(2, mockChannel.ClientRequests.Count); Assert.AreEqual(HttpMethod.Delete.ToString(), mockChannel.ClientRequests[1].Item1.Method); // Check the URI var requestURI = mockChannel.ClientRequests[1].Item1.Address.AbsolutePath; Assert.AreEqual("/Clouds", mockChannel.ClientRequests[0].Item1.Address.AbsolutePath.Substring(1)); Assert.AreEqual(baseURI, mockChannel.ClientRequests[1].Item1.Address.AbsolutePath.Substring(1).Remove(requestURI.IndexOf('(') - 1)); }
public void ShouldCreateOneStaticIPAddressPool() { var mockChannel = new MockRequestChannel(); var staticIPAddressPoolToCreate = new StaticIPAddressPool() { Name = staticIPAddressPoolName, VMSubnetId = Guid.Empty, IPAddressRangeStart = ipAddressRangeStart, IPAddressRangeEnd = ipAddressRangeEnd, StampId = Guid.Empty }; var staticIPAddressPoolToReturn = new StaticIPAddressPool() { Name = staticIPAddressPoolName, IPAddressRangeStart = ipAddressRangeStart, IPAddressRangeEnd = ipAddressRangeEnd, StampId = Guid.Empty }; mockChannel.AddReturnObject(staticIPAddressPoolToReturn, new WebHeaderCollection { "x-ms-request-id:" + Guid.NewGuid() }); Guid?jobOut; var staticIPAddressPoolOperations = new StaticIPAddressPoolOperations(new WebClientFactory(new Subscription(), mockChannel)); var createdStaticIPAddressPool = staticIPAddressPoolOperations.Create(staticIPAddressPoolToCreate, out jobOut); Assert.IsNotNull(createdStaticIPAddressPool); Assert.IsInstanceOfType(createdStaticIPAddressPool, typeof(StaticIPAddressPool)); Assert.AreEqual(staticIPAddressPoolToReturn.Name, createdStaticIPAddressPool.Name); Assert.AreEqual(staticIPAddressPoolToReturn.VMSubnetId, createdStaticIPAddressPool.VMSubnetId); Assert.AreEqual(staticIPAddressPoolToReturn.IPAddressRangeStart, createdStaticIPAddressPool.IPAddressRangeStart); Assert.AreEqual(staticIPAddressPoolToReturn.IPAddressRangeEnd, createdStaticIPAddressPool.IPAddressRangeEnd); Assert.AreEqual(staticIPAddressPoolToReturn.StampId, createdStaticIPAddressPool.StampId); var requestList = mockChannel.ClientRequests; Assert.AreEqual(1, requestList.Count); Assert.AreEqual(HttpMethod.Post.ToString(), requestList[0].Item1.Method); // Check the URI Assert.AreEqual(baseURI, mockChannel.ClientRequests[0].Item1.Address.AbsolutePath.Substring(1)); }
public static StaticIPAddressPool CreateStaticIPAddressPool(global::System.Collections.ObjectModel.ObservableCollection<string> dNSSearchSuffixes, global::System.Collections.ObjectModel.ObservableCollection<string> dNSServers, global::System.Collections.ObjectModel.ObservableCollection<string> wINSServers, global::System.Collections.ObjectModel.ObservableCollection<string> defaultGatewayIPAddresses, global::System.Guid stampId, global::System.Guid ID) { StaticIPAddressPool staticIPAddressPool = new StaticIPAddressPool(); if ((dNSSearchSuffixes == null)) { throw new global::System.ArgumentNullException("dNSSearchSuffixes"); } staticIPAddressPool.DNSSearchSuffixes = dNSSearchSuffixes; if ((dNSServers == null)) { throw new global::System.ArgumentNullException("dNSServers"); } staticIPAddressPool.DNSServers = dNSServers; if ((wINSServers == null)) { throw new global::System.ArgumentNullException("wINSServers"); } staticIPAddressPool.WINSServers = wINSServers; if ((defaultGatewayIPAddresses == null)) { throw new global::System.ArgumentNullException("defaultGatewayIPAddresses"); } staticIPAddressPool.DefaultGatewayIPAddresses = defaultGatewayIPAddresses; staticIPAddressPool.StampId = stampId; staticIPAddressPool.ID = ID; return staticIPAddressPool; }