Beispiel #1
0
        public void ShouldCreateOneCloudService()
        {
            var mockChannel = new MockRequestChannel();

            var cloudServiceToCreate = new Commands.Utilities.WAPackIaaS.DataContract.CloudService {
                Name = cloudServiceName, Label = cloudServiceLabel
            };
            var cloudServiceToReturn = new Commands.Utilities.WAPackIaaS.DataContract.CloudService
            {
                Name  = cloudServiceName,
                Label = cloudServiceLabel,
            };

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

            Guid?jobOut;
            var  cloudServiceOperations = new CloudServiceOperations(new WebClientFactory(new Subscription(), mockChannel));
            var  createdCloudService    = cloudServiceOperations.Create(cloudServiceToCreate, out jobOut);

            Assert.NotNull(createdCloudService);
            Assert.True(createdCloudService is Commands.Utilities.WAPackIaaS.DataContract.CloudService);
            Assert.Equal(cloudServiceToReturn.Name, createdCloudService.Name);
            Assert.Equal(cloudServiceToReturn.Label, createdCloudService.Label);

            var requestList = mockChannel.ClientRequests;

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

            // Check the URI (for Azure consistency)
            Assert.Equal(baseURI, mockChannel.ClientRequests[0].Item1.Address.AbsolutePath.Substring(1));
        }
        public void ShouldCreateOneCloudService()
        {
            var mockChannel = new MockRequestChannel();

            var cloudServiceToCreate = new Commands.Utilities.WAPackIaaS.DataContract.CloudService { Name = cloudServiceName, Label = cloudServiceLabel };
            var cloudServiceToReturn = new Commands.Utilities.WAPackIaaS.DataContract.CloudService
            {
                Name = cloudServiceName,
                Label = cloudServiceLabel,
            };
            mockChannel.AddReturnObject(cloudServiceToReturn, new WebHeaderCollection { "x-ms-request-id:" + Guid.NewGuid() });

            Guid? jobOut;
            var cloudServiceOperations = new CloudServiceOperations(new WebClientFactory(new Subscription(), mockChannel));
            var createdCloudService = cloudServiceOperations.Create(cloudServiceToCreate, out jobOut);

            Assert.NotNull(createdCloudService);
            Assert.True(createdCloudService is Commands.Utilities.WAPackIaaS.DataContract.CloudService);
            Assert.Equal(cloudServiceToReturn.Name, createdCloudService.Name);
            Assert.Equal(cloudServiceToReturn.Label, createdCloudService.Label);

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

            // Check the URI (for Azure consistency)
            Assert.Equal(baseURI, mockChannel.ClientRequests[0].Item1.Address.AbsolutePath.Substring(1));
        }