本文整理汇总了C#中TestContext.GetClient方法的典型用法代码示例。如果您正苦于以下问题:C# TestContext.GetClient方法的具体用法?C# TestContext.GetClient怎么用?C# TestContext.GetClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestContext
的用法示例。
在下文中一共展示了TestContext.GetClient方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGetClusterInfo
public async Task TestGetClusterInfo()
{
// arrange
var ctx = new TestContext();
var urlProvider = ctx.UrlProviderFake;
var restReqExecutor = ctx.RestRequestExecutorFake;
var anyUri = Enumerable.Repeat(new Uri("anyscheme://anypath"), 1);
urlProvider.GetUrlAsync().Returns(Task.FromResult(anyUri));
var anyClusterInfo = new ClusterInfo
{
HadoopBuildVersion = "AnyBuildVersion",
HadoopVersion = "AnyVersion",
HadoopVersionBuiltOn = "AnyVersionBuildOn",
};
restReqExecutor.ExecuteAsync<ClusterInfo>(
Arg.Is<RestRequest>(
req =>
req.Resource == "ws/v1/cluster/info" && req.RootElement == "clusterInfo" &&
req.Method == Method.GET),
anyUri.First(),
CancellationToken.None).Returns(Task.FromResult(anyClusterInfo));
// act
var yarnClient = ctx.GetClient();
ClusterInfo actualClusterInfo = await yarnClient.GetClusterInfoAsync();
// assert
Assert.Equal(anyClusterInfo, actualClusterInfo);
var unused = urlProvider.Received(1).GetUrlAsync();
}
示例2: TestGetApplication
public async Task TestGetApplication()
{
var ctx = new TestContext();
var urlProvider = ctx.UrlProviderFake;
var restReqExecutor = ctx.RestRequestExecutorFake;
var anyUri = Enumerable.Repeat(new Uri("anyscheme://anypath"), 1);
const string applicationId = "AnyApplicationId";
urlProvider.GetUrlAsync().Returns(Task.FromResult(anyUri));
var anyApplication = new Application
{
AllocatedMB = 100,
AmHostHttpAddress = "http://anyhttpaddress",
AmContainerLogs = "SomeLogs",
ApplicationType = "AnyYarnApplicationType",
State = State.FINISHED,
Name = "AnyApplicationName",
RunningContainers = 0
};
restReqExecutor.ExecuteAsync<Application>(
Arg.Is<RestRequest>(
req =>
req.Resource == "ws/v1/cluster/apps/" + applicationId
&& req.RootElement == "app"
&& req.Method == Method.GET),
anyUri.First(),
CancellationToken.None).Returns(Task.FromResult(anyApplication));
var yarnClient = ctx.GetClient();
Application actualApplication = await yarnClient.GetApplicationAsync(applicationId);
Assert.Equal(anyApplication, actualApplication);
var unused = urlProvider.Received(1).GetUrlAsync();
}
示例3: TestGetClusterMetrics
public async Task TestGetClusterMetrics()
{
var ctx = new TestContext();
var urlProvider = ctx.UrlProviderFake;
var restReqExecutor = ctx.RestRequestExecutorFake;
var anyUri = Enumerable.Repeat(new Uri("anyscheme://anypath"), 1);
urlProvider.GetUrlAsync().Returns(Task.FromResult(anyUri));
var anyClusterMetrics = new ClusterMetrics
{
ActiveNodes = 5,
AllocatedMB = 1000,
AllocatedVirtualCores = 10,
AppsCompleted = 301
};
restReqExecutor.ExecuteAsync<ClusterMetrics>(
Arg.Is<RestRequest>(
req =>
req.Resource == "ws/v1/cluster/metrics" && req.RootElement == "clusterMetrics" &&
req.Method == Method.GET),
anyUri.First(),
CancellationToken.None).Returns(Task.FromResult(anyClusterMetrics));
var yarnClient = ctx.GetClient();
ClusterMetrics actualClusterMetrics = await yarnClient.GetClusterMetricsAsync();
Assert.Equal(anyClusterMetrics, actualClusterMetrics);
var unused = urlProvider.Received(1).GetUrlAsync();
}
示例4: TestSubmitNewApplication
//.........这里部分代码省略.........
Entries = new List<YARN.RestClient.DataModel.KeyValuePair<string, LocalResourcesValue>>
{
new YARN.RestClient.DataModel.KeyValuePair<string, LocalResourcesValue>
{
Key = "APPLICATIONWILLFAILBUTWEDONTCAREHERE",
Value = new LocalResourcesValue
{
Resource = "Foo",
Type = ResourceType.FILE,
Visibility = Visibility.APPLICATION
}
}
}
}
}
};
const string expectedJson = @"{" +
@"""application-id"":""AnyApplicationId""," +
@"""application-name"":""AnyAPP""," +
@"""queue"":null,""priority"":1," +
@"""am-container-spec"":" +
@"{" +
@"""local-resources"":" +
@"{" +
@"""entry"":" +
@"[" +
@"{" +
@"""key"":""APPLICATIONWILLFAILBUTWEDONTCAREHERE""," +
@"""value"":" +
@"{" +
@"""resource"":""Foo""," +
@"""type"":""FILE""," +
@"""visibility"":""APPLICATION""," +
@"""size"":0," +
@"""timestamp"":0" +
@"}" +
@"}" +
@"]" +
@"}," +
@"""environment"":null," +
@"""commands"":" +
@"{" +
@"""command"":""DONTCARE""" +
@"}," +
@"""service-data"":null," +
@"""credentials"":null," +
@"""application-acls"":null}," +
@"""unmanaged-AM"":false," +
@"""max-app-attempts"":1," +
@"""resource"":" +
@"{" +
@"""memory"":500," +
@"""vCores"":1" +
@"},""application-type"":""REEFTest""," +
@"""keep-containers-across-application-attempts"":false," +
@"""application-tags"":null" +
@"}";
var thisApplication = new Application
{
AllocatedMB = 100,
AmHostHttpAddress = "http://anyhttpaddress",
AmContainerLogs = "SomeLogs",
ApplicationType = "AnyYarnApplicationType",
State = State.FINISHED,
Name = "AnyApplicationName",
RunningContainers = 0
};
var response = new RestResponse<VoidResult>
{
StatusCode = HttpStatusCode.Accepted
};
restReqExecutor.ExecuteAsync(
Arg.Is<RestRequest>(
req =>
req.Resource == "ws/v1/cluster/apps"
&& req.Method == Method.POST
&& req.Content.Headers.ContentType.MediaType == "application/json"
&& IsExpectedJson(req, expectedJson)),
anyUri.First(),
CancellationToken.None).Returns(Task.FromResult(response));
restReqExecutor.ExecuteAsync<Application>(
Arg.Is<RestRequest>(
req =>
req.Resource == "ws/v1/cluster/apps/" + applicationId
&& req.RootElement == "app"
&& req.Method == Method.GET),
anyUri.First(),
CancellationToken.None).Returns(Task.FromResult(thisApplication));
var yarnClient = ctx.GetClient();
Application actualApplication = await yarnClient.SubmitApplicationAsync(anySubmitApplication);
Assert.Equal(thisApplication, actualApplication);
var unused = urlProvider.Received(2).GetUrlAsync();
}
示例5: TestCreateNewApplication
public async Task TestCreateNewApplication()
{
var ctx = new TestContext();
var urlProvider = ctx.UrlProviderFake;
var restReqExecutor = ctx.RestRequestExecutorFake;
var anyUri = Enumerable.Repeat(new Uri("anyscheme://anypath"), 1);
const string applicationId = "AnyApplicationId";
urlProvider.GetUrlAsync().Returns(Task.FromResult(anyUri));
var anyNewApplication = new NewApplication
{
ApplicationId = applicationId
};
restReqExecutor.ExecuteAsync<NewApplication>(
Arg.Is<RestRequest>(
req =>
req.Resource == "ws/v1/cluster/apps/new-application"
&& req.Method == Method.POST),
anyUri.First(),
CancellationToken.None).Returns(Task.FromResult(anyNewApplication));
var yarnClient = ctx.GetClient();
NewApplication actualNewApplication = await yarnClient.CreateNewApplicationAsync();
Assert.Equal(anyNewApplication, actualNewApplication);
var unused = urlProvider.Received(1).GetUrlAsync();
}