Inheritance: global::System.ComponentModel.INotifyPropertyChanged
        public void ShouldCreateOneVMSubnet()
        {
            var mockChannel = new MockRequestChannel();

            var vmSubnetToCreate = new VMSubnet()
            {
                Name = vmSubnetName,
                VMNetworkName = vmNetworkName,
                VMNetworkId = Guid.Empty,
                Subnet = subnet,
                StampId = Guid.Empty
            };

            var vmSubnetToReturn = new VMSubnet()
            {
                Name = vmSubnetName,
                VMNetworkName = vmNetworkName,
                VMNetworkId = Guid.Empty,
                Subnet = subnet,
                StampId = Guid.Empty
            };

            mockChannel.AddReturnObject(vmSubnetToReturn, new WebHeaderCollection { "x-ms-request-id:" + Guid.NewGuid() });

            Guid? jobOut;
            var vmSubnetOperations = new VMSubnetOperations(new WebClientFactory(new Subscription(), mockChannel));
            var createdVMSubnet = vmSubnetOperations.Create(vmSubnetToCreate, out jobOut);

            Assert.NotNull(createdVMSubnet);
            Assert.True(createdVMSubnet is VMSubnet);
            Assert.Equal(vmSubnetToReturn.Name, createdVMSubnet.Name);
            Assert.Equal(vmSubnetToReturn.VMNetworkName, createdVMSubnet.VMNetworkName);
            Assert.Equal(vmSubnetToReturn.VMNetworkId, createdVMSubnet.VMNetworkId);
            Assert.Equal(vmSubnetToReturn.Subnet, createdVMSubnet.Subnet);
            Assert.Equal(vmSubnetToReturn.StampId, createdVMSubnet.StampId);

            var requestList = mockChannel.ClientRequests;
            Assert.Equal(1, requestList.Count);
            Assert.Equal(HttpMethod.Post.ToString(), requestList[0].Item1.Method);

            // Check the URI
            Assert.Equal(baseURI, mockChannel.ClientRequests[0].Item1.Address.AbsolutePath.Substring(1));
        }
        public override void ExecuteCmdlet()
        {
            var vmSubnet = new VMSubnet()
            {
                Name = this.Name,
                VMNetworkName = this.VNet.Name,
                VMNetworkId = this.VNet.ID,
                Subnet = this.Subnet,
                StampId = this.VNet.StampId,
            };

            Guid? jobId = Guid.Empty;
            var vmSubnetOperations = new VMSubnetOperations(this.WebClientFactory);
            var createdVMSubnet = vmSubnetOperations.Create(vmSubnet, out jobId);
            WaitForJobCompletion(jobId);

            var filter = new Dictionary<string, string>
            {
                {"ID", createdVMSubnet.ID.ToString()},
                {"StampId ", createdVMSubnet.StampId.ToString()}
            };
            var results = vmSubnetOperations.Read(filter);
            this.GenerateCmdletOutput(results);
        }
        public void ShouldReturnOneVMSubnet()
        {
            const string subnet = "192.168.1.0/24";
            const string vmNetworkName = "VNet01";
            const string vmSubnetName = "VMSubnet01";

            var mockChannel = new MockRequestChannel();

            var vmSubnetToCreate = new VMSubnet()
            {
                Name = vmSubnetName,
                VMNetworkName = vmNetworkName,
                VMNetworkId = Guid.Empty,
                Subnet = subnet,
                StampId = Guid.Empty
            };
            mockChannel.AddReturnObject(vmSubnetToCreate);

            var vmSubnetOperations = new VMSubnetOperations(new WebClientFactory(new Subscription(), mockChannel));
            var readStaticIPAddressPool = vmSubnetOperations.Read(new VMNetwork() { StampId = Guid.Empty, ID = Guid.Empty });
            Assert.Equal(1, readStaticIPAddressPool.Count);

            // Check the URI
            var requestList = mockChannel.ClientRequests;
            Assert.Equal(1, requestList.Count);
            Assert.Equal(baseURI, mockChannel.ClientRequests[0].Item1.Address.AbsolutePath.Substring(1));
        }
        public void ShouldDeleteVMSubnet()
        {
            const string subnet = "192.168.1.0/24";
            const string vmNetworkName = "VNet01";
            const string vmSubnetName = "VMSubnet01";

            var mockChannel = new MockRequestChannel();

            var existingVMSubnet = new VMSubnet()
            {
                Name = vmSubnetName,
                VMNetworkName = vmNetworkName,
                VMNetworkId = Guid.Empty,
                Subnet = subnet,
                StampId = Guid.Empty
            };
            mockChannel.AddReturnObject(new Cloud() { StampId = Guid.NewGuid() });
            mockChannel.AddReturnObject(existingVMSubnet, new WebHeaderCollection { "x-ms-request-id:" + Guid.NewGuid() });

            Guid? jobOut;
            var vmSubnetOperations = new VMSubnetOperations(new WebClientFactory(new Subscription(), mockChannel));
            vmSubnetOperations.Delete(Guid.Empty, out jobOut);

            Assert.Equal(2, mockChannel.ClientRequests.Count);
            Assert.Equal(HttpMethod.Delete.ToString(), mockChannel.ClientRequests[1].Item1.Method);

            // Check the URI
            var requestURI = mockChannel.ClientRequests[1].Item1.Address.AbsolutePath;
            Assert.Equal("/Clouds", mockChannel.ClientRequests[0].Item1.Address.AbsolutePath.Substring(1));
            Assert.Equal(baseURI, mockChannel.ClientRequests[1].Item1.Address.AbsolutePath.Substring(1).Remove(requestURI.IndexOf('(') - 1));
        }