本文整理汇总了C#中Page.SetItemValue方法的典型用法代码示例。如果您正苦于以下问题:C# Page.SetItemValue方法的具体用法?C# Page.SetItemValue怎么用?C# Page.SetItemValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page.SetItemValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetProviderFeatureTests
public void GetProviderFeatureTests()
{
// setup return values
const string Provider1Namespace = "Providers.Test1";
const string Feature1Name = "feature1";
const string Provider2Namespace = "Providers.Test2";
const string Feature2Name = "feature2";
var provider1RegisteredFeature = new FeatureResult
{
Id = "featureId1",
Name = Provider1Namespace + "/" + Feature1Name,
Properties = new FeatureProperties
{
State = ProviderFeatureClient.RegisteredStateName,
},
Type = "Microsoft.Features/feature"
};
var provider1UnregisteredFeature = new FeatureResult
{
Id = "featureId1",
Name = Provider1Namespace + "/" + Feature2Name,
Properties = new FeatureProperties
{
State = "Unregistered",
},
Type = "Microsoft.Features/feature"
};
var provider2UnregisteredFeature = new FeatureResult
{
Id = "featureId2",
Name = Provider2Namespace + "/" + Feature1Name,
Properties = new FeatureProperties
{
State = "Unregistered",
},
Type = "Microsoft.Features/feature"
};
var pagableResult = new Page<FeatureResult>();
//var listResult = new[] { provider1RegisteredFeature, provider1UnregisteredFeature, provider2UnregisteredFeature };
var listResult = new List<FeatureResult>() { provider1RegisteredFeature, provider1UnregisteredFeature, provider2UnregisteredFeature };
pagableResult.SetItemValue<FeatureResult>(listResult);
var result = new AzureOperationResponse<IPage<FeatureResult>>()
{
Body = pagableResult
};
this.featureOperationsMock
.Setup(f => f.ListAllWithHttpMessagesAsync(null, It.IsAny<CancellationToken>()))
.Returns(() => Task.FromResult(result));
// 1. List only registered features of providers
this.commandRuntimeMock
.Setup(m => m.WriteObject(It.IsAny<object>()))
.Callback((object obj) =>
{
Assert.IsType<PSProviderFeature[]>(obj);
var features = (PSProviderFeature[])obj;
Assert.Equal(1, features.Length);
var provider = features.Single();
Assert.Equal(Provider1Namespace, provider.ProviderName, StringComparer.OrdinalIgnoreCase);
Assert.Equal(Feature1Name, provider.FeatureName, StringComparer.OrdinalIgnoreCase);
Assert.Equal(ProviderFeatureClient.RegisteredStateName, provider.RegistrationState, StringComparer.OrdinalIgnoreCase);
});
this.cmdlet.ParameterSetOverride = GetAzureProviderFeatureCmdlet.ListAvailableParameterSet;
this.cmdlet.ExecuteCmdlet();
this.VerifyListAllCallPatternAndReset();
// 2. List all features of all providers
this.cmdlet.ListAvailable = true;
this.commandRuntimeMock
.Setup(m => m.WriteObject(It.IsAny<object>()))
.Callback((object obj) =>
{
Assert.IsType<PSProviderFeature[]>(obj);
var features = (PSProviderFeature[])obj;
Assert.Equal(listResult.Count(), features.Length);
});
this.cmdlet.ExecuteCmdlet();
this.VerifyListAllCallPatternAndReset();
// 3.a. List only registered features of a particular provider - and they exist
string providerOfChoice = Provider1Namespace;
this.cmdlet.ListAvailable = false;
this.cmdlet.ProviderNamespace = providerOfChoice;
//pagableResult.SetItemValue<FeatureResult>(new List<FeatureResult>() { provider1RegisteredFeature, provider1UnregisteredFeature });
this.featureOperationsMock
//.........这里部分代码省略.........
示例2: GetsResourceProviderTests
public void GetsResourceProviderTests()
{
//setup return values
const string RegisteredProviderNamespace = "Providers.Test1";
const string UnregisteredProviderNamespace = "Providers.Test2";
const string ResourceTypeName = "TestResource1";
var unregisteredProvider = new Provider
{
NamespaceProperty = UnregisteredProviderNamespace,
RegistrationState = "Unregistered",
ResourceTypes = new[]
{
new ProviderResourceType
{
Locations = new[] {"West US", "East US", "South US"},
ResourceType = "TestResource2"
}
}
};
var listResult = new List<Provider>()
{
new Provider
{
NamespaceProperty = RegisteredProviderNamespace,
RegistrationState = ResourceManagerSdkClient.RegisteredStateName,
ResourceTypes = new[]
{
new ProviderResourceType
{
Locations = new[] { "West US", "East US" },
//Name = ResourceTypeName,
}
}
},
unregisteredProvider,
};
var pagableResult = new Page<Provider>();
pagableResult.SetItemValue<Provider>(listResult);
var result = new AzureOperationResponse<IPage<Provider>>()
{
Body = pagableResult
};
this.providerOperationsMock
.Setup(f => f.ListWithHttpMessagesAsync(null, null, null, It.IsAny<CancellationToken>()))
.Returns(() => Task.FromResult(result));
var locationList = new List<Location>
{
new Location
{
Name = "southus",
DisplayName = "South US",
}
};
var pagableLocations = new Page<Location>();
pagableLocations.SetItemValue<Location>(locationList);
var locationsResult = new AzureOperationResponse<IEnumerable<Location>>()
{
Body = pagableLocations
};
this.subscriptionsOperationsMock
.Setup(f => f.ListLocationsWithHttpMessagesAsync(It.IsAny<string>(), null, It.IsAny<CancellationToken>()))
.Returns(() => Task.FromResult(locationsResult));
// 1. List only registered providers
this.commandRuntimeMock
.Setup(m => m.WriteObject(It.IsAny<object>()))
.Callback((object obj) =>
{
Assert.IsType<PSResourceProvider[]>(obj);
var providers = (PSResourceProvider[])obj;
Assert.Equal(1, providers.Length);
var provider = providers.Single();
Assert.Equal(RegisteredProviderNamespace, provider.ProviderNamespace);
Assert.Equal(ResourceManagerSdkClient.RegisteredStateName, provider.RegistrationState);
Assert.Equal(1, provider.ResourceTypes.Length);
var resourceType = provider.ResourceTypes.Single();
Assert.Equal(ResourceTypeName, resourceType.ResourceTypeName);
Assert.Equal(2, resourceType.Locations.Length);
});
this.cmdlet.ParameterSetOverride = GetAzureProviderCmdlet.ListAvailableParameterSet;
this.cmdlet.ExecuteCmdlet();
this.VerifyListCallPatternAndReset();
// 2. List all providers
this.cmdlet.ListAvailable = true;
this.commandRuntimeMock
.Setup(m => m.WriteObject(It.IsAny<object>()))
//.........这里部分代码省略.........