예제 #1
0
        public void ResourceCriteria_ResourceType_SetProperty_Expect_SetValue()
        {
            //-----------------Arrange-------------------
            var resourceCriteria = new ResourceCriteria();

            var resourceType = "TestResourceType";

            //-----------------Act-----------------------
            resourceCriteria.ResourceType = resourceType;
            //-----------------Assert--------------------
            Assert.AreEqual(resourceType, resourceCriteria.ResourceType);
        }
예제 #2
0
        public void ResourceCriteria_VersionInfo_SetProperty_Expect_SetValue()
        {
            //-----------------Arrange-------------------
            var mockVersionInfo = new Mock <IVersionInfo>();

            var resourceCriteria = new ResourceCriteria();

            //-----------------Act-----------------------
            resourceCriteria.VersionInfo = mockVersionInfo.Object;
            //-----------------Assert--------------------
            Assert.AreEqual(mockVersionInfo.Object, resourceCriteria.VersionInfo);
        }
예제 #3
0
        public void ResourceCriteria_ResourceID_SetProperty_Expect_SetValue()
        {
            //-----------------Arrange-------------------
            var resourceCriteria = new ResourceCriteria();

            var resourceID = Guid.NewGuid();

            //-----------------Act-----------------------
            resourceCriteria.ResourceID = resourceID;
            //-----------------Assert--------------------
            Assert.AreEqual(resourceID, resourceCriteria.ResourceID);
        }
예제 #4
0
        public void ResourceCriteria_ResourcePath_SetProperty_Expect_SetValue()
        {
            //-----------------Arrange-------------------
            var resourceCriteria = new ResourceCriteria();

            var resourcePath = "TestResourcePath";

            //-----------------Act-----------------------
            resourceCriteria.ResourcePath = resourcePath;
            //-----------------Assert--------------------
            Assert.AreEqual(resourcePath, resourceCriteria.ResourcePath);
        }
예제 #5
0
        public void ResourceCriteria_FetchAll_SetProperty_Expect_SetValue()
        {
            //-----------------Arrange-------------------
            var fetchAll = true;

            var resourceCriteria = new ResourceCriteria();

            //-----------------Act-----------------------
            resourceCriteria.FetchAll = fetchAll;
            //-----------------Assert--------------------
            Assert.AreEqual(fetchAll, resourceCriteria.FetchAll);
        }
예제 #6
0
        public void ResourceCriteria_AuthorRoles_SetProperty_Expect_SetValue()
        {
            //-----------------Arrange-------------------
            var authorRoles = "testAuthorRoles";

            var resourceCriteria = new ResourceCriteria();

            //-----------------Act-----------------------
            resourceCriteria.AuthorRoles = authorRoles;
            //-----------------Assert--------------------
            Assert.AreEqual(authorRoles, resourceCriteria.AuthorRoles);
        }
예제 #7
0
        public void ResourceCriteria_IsNewResource_SetProperty_Expect_SetValue()
        {
            //-----------------Arrange-------------------
            var isNewResource = true;

            var resourceCriteria = new ResourceCriteria();

            //-----------------Act-----------------------
            resourceCriteria.IsNewResource = isNewResource;
            //-----------------Assert--------------------
            Assert.IsTrue(resourceCriteria.IsNewResource);
        }
예제 #8
0
        public void ResourceCriteria_GuidCsv_SetProperty_Expect_SetValue()
        {
            //-----------------Arrange-------------------
            var guidCsv = "TestGuidCsv";

            var resourceCriteria = new ResourceCriteria();

            //-----------------Act-----------------------
            resourceCriteria.GuidCsv = guidCsv;
            //-----------------Assert--------------------
            Assert.AreEqual(guidCsv, resourceCriteria.GuidCsv);
        }
예제 #9
0
        public void ResourceCriteria_IsUpgraded_SetProperty_Expect_SetValue()
        {
            //-----------------Arrange-------------------
            var isUpgraded = false;

            var resourceCriteria = new ResourceCriteria();

            //-----------------Act-----------------------
            resourceCriteria.IsUpgraded = isUpgraded;
            //-----------------Assert--------------------
            Assert.AreEqual(isUpgraded, resourceCriteria.IsUpgraded);
        }
예제 #10
0
        public void ResourceCriteria_WorkspaceId_SetProperty_Expect_SetValue()
        {
            //-----------------Arrange-------------------
            var workspaceId = Guid.NewGuid();

            var resourceCriteria = new ResourceCriteria();

            //-----------------Act-----------------------
            resourceCriteria.WorkspaceId = workspaceId;
            //-----------------Assert--------------------
            Assert.AreEqual(workspaceId, resourceCriteria.WorkspaceId);
        }
예제 #11
0
        public override string DefineQuery(ResourceCriteria criteria)
        {
            var query = GraphQueryBuilder.ForResourceType(ResourceType)
                        .WithSubscriptionsWithIds(criteria.Subscriptions) // Filter on queried subscriptions defined in landscape
                        .WithResourceGroupsWithName(criteria.ResourceGroups)
                        .WithinRegions(criteria.Regions)
                        .WithTags(criteria.Tags)
                        .Project("subscriptionId", "resourceGroup", "type", "name")
                        .Build();

            return(query);
        }
예제 #12
0
        public override string DefineQuery(ResourceCriteria criteria)
        {
            var query = GraphQueryBuilder.ForResourceType("microsoft.web/sites", "microsoft.web/sites/slots")
                        .Where("kind", Operator.DoesNotContain, "functionapp")
                        .WithSubscriptionsWithIds(criteria.Subscriptions) // Filter on queried subscriptions defined in landscape
                        .WithResourceGroupsWithName(criteria.ResourceGroups)
                        .WithinRegions(criteria.Regions)
                        .WithTags(criteria.Tags)
                        .Project("subscriptionId", "resourceGroup", "type", "name")
                        .Build();

            return(query);
        }
        public async Task <List <Resource> > QueryAsync(string resourceType, ResourceCriteria criteria)
        {
            Guard.NotNullOrWhitespace(resourceType, nameof(resourceType));
            Guard.NotNull(criteria, nameof(criteria));
            Guard.NotNull(criteria.Subscriptions, nameof(criteria.Subscriptions));
            Guard.NotNull(criteria.Regions, nameof(criteria.Regions));
            Guard.NotNull(criteria.ResourceGroups, nameof(criteria.ResourceGroups));
            Guard.NotNull(criteria.Tags, nameof(criteria.Tags));

            var query = GraphQuery.ForResourceType(resourceType)
                        .WithSubscriptionsWithIds(criteria.Subscriptions) // Filter on queried subscriptions defined in landscape
                        .WithResourceGroupsWithName(criteria.ResourceGroups)
                        .WithinRegions(criteria.Regions)
                        .WithTags(criteria.Tags)
                        .Project("subscriptionId", "resourceGroup", "type", "name", "id")
                        .Build();

            return(await QueryAsync(query, Subscriptions));
        }
예제 #14
0
 public abstract string DefineQuery(ResourceCriteria criteria);