コード例 #1
0
        public void ContainerInstanceListTest()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (MockContext context = MockContext.Start(this.GetType().FullName))
            {
                var resourceClient          = ContainerInstanceTestUtilities.GetResourceManagementClient(context, handler);
                var containerInstanceClient = ContainerInstanceTestUtilities.GetContainerInstanceManagementClient(context, handler);

                // Create 2 container groups.
                var resourceGroup1      = ContainerInstanceTestUtilities.CreateResourceGroup(resourceClient);
                var containerGroupName1 = TestUtilities.GenerateName("acinetsdk");
                var containerGroup1     = ContainerInstanceTestUtilities.CreateTestContainerGroup(containerGroupName1);
                containerInstanceClient.ContainerGroups.CreateOrUpdate(resourceGroup1.Name, containerGroupName1, containerGroup1);

                var resourceGroup2      = ContainerInstanceTestUtilities.CreateResourceGroup(resourceClient);
                var containerGroupName2 = TestUtilities.GenerateName("acinetsdk");
                var containerGroup2     = ContainerInstanceTestUtilities.CreateTestContainerGroup(containerGroupName2);
                containerInstanceClient.ContainerGroups.CreateOrUpdate(resourceGroup2.Name, containerGroupName2, containerGroup2);

                // Verify both container group exist when listing.
                var retrievedContainerGroups = containerInstanceClient.ContainerGroups.List();
                Assert.True(retrievedContainerGroups.Count() >= 2);
                var retrievedContainerGroup1 = retrievedContainerGroups.Where(cg => cg.Name == containerGroupName1).FirstOrDefault();
                ContainerInstanceTestUtilities.VerifyContainerGroupProperties(containerGroup1, retrievedContainerGroup1);
                var retrievedContainerGroup2 = retrievedContainerGroups.Where(cg => cg.Name == containerGroupName2).FirstOrDefault();
                ContainerInstanceTestUtilities.VerifyContainerGroupProperties(containerGroup2, retrievedContainerGroup2);
            }
        }
コード例 #2
0
        public void ContainerInstanceGetTest()
        {
            var handler = new RecordedDelegatingHandler {
                StatusCodeToReturn = HttpStatusCode.OK
            };

            using (MockContext context = MockContext.Start(this.GetType().FullName))
            {
                var resourceClient          = ContainerInstanceTestUtilities.GetResourceManagementClient(context, handler);
                var containerInstanceClient = ContainerInstanceTestUtilities.GetContainerInstanceManagementClient(context, handler);

                var resourceGroup = ContainerInstanceTestUtilities.CreateResourceGroup(resourceClient);

                // Create container group.
                var containerGroupName = TestUtilities.GenerateName("acinetsdk");
                var containerGroup     = ContainerInstanceTestUtilities.CreateTestContainerGroup(containerGroupName);

                // Verify created container group.
                var createdContainerGroup = containerInstanceClient.ContainerGroups.CreateOrUpdate(resourceGroup.Name, containerGroupName, containerGroup);
                ContainerInstanceTestUtilities.VerifyContainerGroupProperties(containerGroup, createdContainerGroup);

                // Verifiy retrieved container group.
                var retrievedContainerGroup = containerInstanceClient.ContainerGroups.Get(resourceGroup.Name, containerGroupName);
                ContainerInstanceTestUtilities.VerifyContainerGroupProperties(containerGroup, retrievedContainerGroup);
            }
        }