public void SubResourceWildcardFilterTest() { WildCardTestCmdlet cmdlet = new WildCardTestCmdlet(); // Id objects Assert.Equal(3, cmdlet.SubResourceWildcardFilter("test1", ReturnedResources).Count); Assert.Empty(cmdlet.SubResourceWildcardFilter("test11", ReturnedResources)); Assert.Empty(cmdlet.SubResourceWildcardFilter("1", ReturnedResources)); Assert.Equal(11, cmdlet.SubResourceWildcardFilter("t*t*", ReturnedResources).Count); Assert.Single(cmdlet.SubResourceWildcardFilter("t*t", ReturnedResources)); Assert.Equal(4, cmdlet.SubResourceWildcardFilter("t*1", ReturnedResources).Count); // ResourceId objects Assert.Equal(3, cmdlet.SubResourceWildcardFilter("test1", ReturnedResources1).Count); Assert.Empty(cmdlet.SubResourceWildcardFilter("test11", ReturnedResources1)); Assert.Empty(cmdlet.SubResourceWildcardFilter("1", ReturnedResources1)); Assert.Equal(11, cmdlet.SubResourceWildcardFilter("t*t*", ReturnedResources1).Count); Assert.Single(cmdlet.SubResourceWildcardFilter("t*t", ReturnedResources1)); Assert.Equal(4, cmdlet.SubResourceWildcardFilter("t*1", ReturnedResources1).Count); // ResoureGroupName/Name objects Assert.Equal(3, cmdlet.SubResourceWildcardFilter("test1", ReturnedResources2).Count); Assert.Empty(cmdlet.SubResourceWildcardFilter("test11", ReturnedResources2)); Assert.Empty(cmdlet.SubResourceWildcardFilter("1", ReturnedResources2)); Assert.Equal(11, cmdlet.SubResourceWildcardFilter("t*t*", ReturnedResources2).Count); Assert.Single(cmdlet.SubResourceWildcardFilter("t*t", ReturnedResources2)); Assert.Equal(4, cmdlet.SubResourceWildcardFilter("t*1", ReturnedResources2).Count); }
public void ShouldListByResourceGroupTest() { WildCardTestCmdlet cmdlet = new WildCardTestCmdlet(); Assert.False(cmdlet.ShouldListByResourceGroup(null, null)); Assert.False(cmdlet.ShouldListByResourceGroup("*", null)); Assert.False(cmdlet.ShouldListByResourceGroup("testrg*", null)); Assert.False(cmdlet.ShouldListByResourceGroup("*testrg*", null)); Assert.False(cmdlet.ShouldListByResourceGroup("test*rg", null)); Assert.True(cmdlet.ShouldListByResourceGroup("testrg", null)); Assert.False(cmdlet.ShouldListByResourceGroup(null, "*")); Assert.False(cmdlet.ShouldListByResourceGroup("*", "*")); Assert.False(cmdlet.ShouldListByResourceGroup("testrg*", "*")); Assert.False(cmdlet.ShouldListByResourceGroup("*testrg*", "*")); Assert.False(cmdlet.ShouldListByResourceGroup("test*rg", "*")); Assert.True(cmdlet.ShouldListByResourceGroup("testrg", "*")); Assert.False(cmdlet.ShouldListByResourceGroup(null, "testname*")); Assert.False(cmdlet.ShouldListByResourceGroup("*", "testname*")); Assert.False(cmdlet.ShouldListByResourceGroup("testrg*", "testname*")); Assert.False(cmdlet.ShouldListByResourceGroup("*testrg*", "testname*")); Assert.False(cmdlet.ShouldListByResourceGroup("test*rg", "testname*")); Assert.True(cmdlet.ShouldListByResourceGroup("testrg", "testname*")); Assert.False(cmdlet.ShouldListByResourceGroup(null, "*testname*")); Assert.False(cmdlet.ShouldListByResourceGroup("*", "*testname*")); Assert.False(cmdlet.ShouldListByResourceGroup("testrg*", "*testname*")); Assert.False(cmdlet.ShouldListByResourceGroup("*testrg*", "*testname*")); Assert.False(cmdlet.ShouldListByResourceGroup("test*rg", "*testname*")); Assert.True(cmdlet.ShouldListByResourceGroup("testrg", "*testname*")); Assert.False(cmdlet.ShouldListByResourceGroup(null, "testname")); Assert.False(cmdlet.ShouldListByResourceGroup("*", "testname")); Assert.False(cmdlet.ShouldListByResourceGroup("testrg*", "testname")); Assert.False(cmdlet.ShouldListByResourceGroup("*testrg*", "testname")); Assert.False(cmdlet.ShouldListByResourceGroup("test*rg", "testname")); Assert.False(cmdlet.ShouldListByResourceGroup("testrg", "testname")); }
public void ShouldGetByNameTest() { WildCardTestCmdlet cmdlet = new WildCardTestCmdlet(); Assert.False(cmdlet.ShouldGetByName(null, null)); Assert.False(cmdlet.ShouldGetByName("*", null)); Assert.False(cmdlet.ShouldGetByName("testrg*", null)); Assert.False(cmdlet.ShouldGetByName("*testrg*", null)); Assert.False(cmdlet.ShouldGetByName("test*rg", null)); Assert.False(cmdlet.ShouldGetByName("testrg", null)); Assert.False(cmdlet.ShouldGetByName(null, "*")); Assert.False(cmdlet.ShouldGetByName("*", "*")); Assert.False(cmdlet.ShouldGetByName("testrg*", "*")); Assert.False(cmdlet.ShouldGetByName("*testrg*", "*")); Assert.False(cmdlet.ShouldGetByName("test*rg", "*")); Assert.False(cmdlet.ShouldGetByName("testrg", "*")); Assert.False(cmdlet.ShouldGetByName(null, "testname*")); Assert.False(cmdlet.ShouldGetByName("*", "testname*")); Assert.False(cmdlet.ShouldGetByName("testrg*", "testname*")); Assert.False(cmdlet.ShouldGetByName("*te?strg*", "testname*")); Assert.False(cmdlet.ShouldGetByName("test*rg", "testname*")); Assert.False(cmdlet.ShouldGetByName("testrg", "testname*")); Assert.False(cmdlet.ShouldGetByName(null, "*testname*")); Assert.False(cmdlet.ShouldGetByName("*", "*testname*")); Assert.False(cmdlet.ShouldGetByName("testrg*", "*testname*")); Assert.False(cmdlet.ShouldGetByName("*testrg*", "*testname*")); Assert.False(cmdlet.ShouldGetByName("test*rg", "*testname*")); Assert.False(cmdlet.ShouldGetByName("testrg", "*testname*")); Assert.False(cmdlet.ShouldGetByName(null, "testname")); Assert.False(cmdlet.ShouldGetByName("*", "testname")); Assert.False(cmdlet.ShouldGetByName("testrg*", "testname")); Assert.False(cmdlet.ShouldGetByName("*testrg*", "testname")); Assert.False(cmdlet.ShouldGetByName("test*rg", "testname")); Assert.True(cmdlet.ShouldGetByName("testrg", "testname")); }
public void ShouldListBySubscriptionTest() { WildCardTestCmdlet cmdlet = new WildCardTestCmdlet(); Assert.True(cmdlet.ShouldListBySubscription(null, null)); Assert.True(cmdlet.ShouldListBySubscription("*", null)); Assert.True(cmdlet.ShouldListBySubscription("testrg*", null)); Assert.True(cmdlet.ShouldListBySubscription("*testrg*", null)); Assert.True(cmdlet.ShouldListBySubscription("test*rg", null)); Assert.False(cmdlet.ShouldListBySubscription("testrg", null)); Assert.True(cmdlet.ShouldListBySubscription(null, "*")); Assert.True(cmdlet.ShouldListBySubscription("*", "*")); Assert.True(cmdlet.ShouldListBySubscription("testrg*", "*")); Assert.True(cmdlet.ShouldListBySubscription("*testrg*", "*")); Assert.True(cmdlet.ShouldListBySubscription("tes*trg", "*")); Assert.False(cmdlet.ShouldListBySubscription("testrg", "*")); Assert.True(cmdlet.ShouldListBySubscription(null, "testname*")); Assert.True(cmdlet.ShouldListBySubscription("*", "testname*")); Assert.True(cmdlet.ShouldListBySubscription("t?estrg*", "testname*")); Assert.True(cmdlet.ShouldListBySubscription("tes[t]rg*", "testname*")); Assert.True(cmdlet.ShouldListBySubscription("test[r]g", "testname*")); Assert.False(cmdlet.ShouldListBySubscription("testrg", "testname*")); Assert.True(cmdlet.ShouldListBySubscription(null, "*testname*")); Assert.True(cmdlet.ShouldListBySubscription("*", "*testname*")); Assert.True(cmdlet.ShouldListBySubscription("testrg*", "*testname*")); Assert.True(cmdlet.ShouldListBySubscription("*testrg*", "*testname*")); Assert.True(cmdlet.ShouldListBySubscription("test*rg", "*testname*")); Assert.False(cmdlet.ShouldListBySubscription("testrg", "*testname*")); Assert.True(cmdlet.ShouldListBySubscription(null, "testname")); Assert.True(cmdlet.ShouldListBySubscription("*", "testname")); Assert.True(cmdlet.ShouldListBySubscription("testrg*", "testname")); Assert.True(cmdlet.ShouldListBySubscription("*testrg*", "testname")); Assert.True(cmdlet.ShouldListBySubscription("test*rg", "testname")); Assert.False(cmdlet.ShouldListBySubscription("testrg", "testname")); }
public void TopLevelWildcardFilterTest() { WildCardTestCmdlet cmdlet = new WildCardTestCmdlet(); // Id objects Assert.Single(cmdlet.TopLevelWildcardFilter("resourcegroup1", "test1", ReturnedResources)); Assert.Empty(cmdlet.TopLevelWildcardFilter("resourcegroup11", "test1", ReturnedResources)); Assert.Empty(cmdlet.TopLevelWildcardFilter("1", "test1", ReturnedResources)); Assert.Empty(cmdlet.TopLevelWildcardFilter("resourcegroup1", "test11", ReturnedResources)); Assert.Empty(cmdlet.TopLevelWildcardFilter("resourcegroup1", "1", ReturnedResources)); Assert.Equal(3, cmdlet.TopLevelWildcardFilter("r*g*", "test1", ReturnedResources).Count); Assert.Empty(cmdlet.TopLevelWildcardFilter("r*p", "test1", ReturnedResources)); Assert.Single(cmdlet.TopLevelWildcardFilter("r*1", "test1", ReturnedResources)); Assert.Equal(6, cmdlet.TopLevelWildcardFilter("resourcegroup1", "*", ReturnedResources).Count); Assert.Equal(2, cmdlet.TopLevelWildcardFilter("resourcegroup1", "*1", ReturnedResources).Count); Assert.Equal(11, cmdlet.TopLevelWildcardFilter("r*p*", "*", ReturnedResources).Count); Assert.Equal(6, cmdlet.TopLevelWildcardFilter("r*1", "*", ReturnedResources).Count); Assert.Equal(2, cmdlet.TopLevelWildcardFilter("r*1", "*1", ReturnedResources).Count); Assert.Equal(6, cmdlet.TopLevelWildcardFilter("r*1", "t*", ReturnedResources).Count); // ResourceId objects Assert.Single(cmdlet.TopLevelWildcardFilter("resourcegroup1", "test1", ReturnedResources1)); Assert.Empty(cmdlet.TopLevelWildcardFilter("resourcegroup11", "test1", ReturnedResources1)); Assert.Empty(cmdlet.TopLevelWildcardFilter("1", "test1", ReturnedResources1)); Assert.Empty(cmdlet.TopLevelWildcardFilter("resourcegroup1", "test11", ReturnedResources1)); Assert.Empty(cmdlet.TopLevelWildcardFilter("resourcegroup1", "1", ReturnedResources1)); Assert.Equal(3, cmdlet.TopLevelWildcardFilter("r*g*", "test1", ReturnedResources1).Count); Assert.Empty(cmdlet.TopLevelWildcardFilter("r*p", "test1", ReturnedResources1)); Assert.Single(cmdlet.TopLevelWildcardFilter("r*1", "test1", ReturnedResources1)); Assert.Equal(6, cmdlet.TopLevelWildcardFilter("resourcegroup1", "*", ReturnedResources1).Count); Assert.Equal(2, cmdlet.TopLevelWildcardFilter("resourcegroup1", "*1", ReturnedResources1).Count); Assert.Equal(11, cmdlet.TopLevelWildcardFilter("r*p*", "*", ReturnedResources1).Count); Assert.Equal(6, cmdlet.TopLevelWildcardFilter("r*1", "*", ReturnedResources1).Count); Assert.Equal(2, cmdlet.TopLevelWildcardFilter("r*1", "*1", ReturnedResources1).Count); Assert.Equal(6, cmdlet.TopLevelWildcardFilter("r*1", "t*", ReturnedResources1).Count); // ResourceGroupName/Name objects Assert.Single(cmdlet.TopLevelWildcardFilter("resourcegroup1", "test1", ReturnedResources2)); Assert.Empty(cmdlet.TopLevelWildcardFilter("resourcegroup11", "test1", ReturnedResources2)); Assert.Empty(cmdlet.TopLevelWildcardFilter("1", "test1", ReturnedResources2)); Assert.Empty(cmdlet.TopLevelWildcardFilter("resourcegroup1", "test11", ReturnedResources2)); Assert.Empty(cmdlet.TopLevelWildcardFilter("resourcegroup1", "1", ReturnedResources2)); Assert.Equal(3, cmdlet.TopLevelWildcardFilter("r*g*", "test1", ReturnedResources2).Count); Assert.Empty(cmdlet.TopLevelWildcardFilter("r*p", "test1", ReturnedResources2)); Assert.Single(cmdlet.TopLevelWildcardFilter("r*1", "test1", ReturnedResources2)); Assert.Equal(6, cmdlet.TopLevelWildcardFilter("resourcegroup1", "*", ReturnedResources2).Count); Assert.Equal(2, cmdlet.TopLevelWildcardFilter("resourcegroup1", "*1", ReturnedResources2).Count); Assert.Equal(11, cmdlet.TopLevelWildcardFilter("r*p*", "*", ReturnedResources2).Count); Assert.Equal(6, cmdlet.TopLevelWildcardFilter("r*1", "*", ReturnedResources2).Count); Assert.Equal(2, cmdlet.TopLevelWildcardFilter("r*1", "*1", ReturnedResources2).Count); Assert.Equal(6, cmdlet.TopLevelWildcardFilter("r*1", "t*", ReturnedResources2).Count); Assert.Single(cmdlet.TopLevelWildcardFilter("resourcegrouptest", "testserver", ReturnedResourcesWithChild)); Assert.Single(cmdlet.TopLevelWildcardFilter("resourcegrouptest", "testdatabase", ReturnedResourcesWithChild)); Assert.Single(cmdlet.TopLevelWildcardFilter("resourcegrouptest", "testserver/testdatabase", ReturnedResourcesWithChild)); }