本文整理汇总了C#中TestContext.ExecuteCommand方法的典型用法代码示例。如果您正苦于以下问题:C# TestContext.ExecuteCommand方法的具体用法?C# TestContext.ExecuteCommand怎么用?C# TestContext.ExecuteCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestContext
的用法示例。
在下文中一共展示了TestContext.ExecuteCommand方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanUploadToDirectAndLatestWithLongOptions
public async Task CanUploadToDirectAndLatestWithLongOptions()
{
// Arrange
using (var tc = new TestContext(_output))
{
// Act
var actual = tc.ExecuteCommand(
new[]
{
"--connection-string", tc.ConnectionString,
"--container", tc.Container,
"--path-format", tc.PathFormat
},
tc.Content);
// Assert
await tc.VerifyContentAsync(actual, direct: true, latest: true);
}
}
示例2: WritesHelpTextWithShortOptions
public void WritesHelpTextWithShortOptions()
{
// Arrange
using (var tc = new TestContext(_output))
{
// Act
var actual = tc.ExecuteCommand(
new[] { "-h" },
tc.Content);
// Assert
Assert.Equal(CommandStatus.Exited, actual.Status);
Assert.Equal(0, actual.ExitCode);
Assert.Contains("Usage: ToStorage [options]", actual.Output);
}
}
示例3: RequiresContainerOption
public void RequiresContainerOption()
{
// Arrange
using (var tc = new TestContext(_output))
{
// Act
var actual = tc.ExecuteCommand(
new[]
{
"--connection-string", tc.ConnectionString,
"--path-format", tc.PathFormat
},
tc.Content);
// Assert
Assert.Equal(CommandStatus.Exited, actual.Status);
Assert.Equal(1, actual.ExitCode);
Assert.Contains("Error: required option -c, --container is missing.", actual.Error);
}
}
示例4: RequiresConnectionStringAndContainerOptions
public void RequiresConnectionStringAndContainerOptions()
{
// Arrange
using (var tc = new TestContext(_output))
{
// Act
var actual = tc.ExecuteCommand(
Enumerable.Empty<string>(),
tc.Content);
// Assert
Assert.Equal(CommandStatus.Exited, actual.Status);
Assert.Equal(1, actual.ExitCode);
Assert.Contains("Error: required option -s, --connection-string is missing.", actual.Error);
Assert.Contains("Error: required option -c, --container is missing.", actual.Error);
}
}
示例5: HasDefaultPathFormat
public async Task HasDefaultPathFormat()
{
// Arrange
using (var tc = new TestContext(_output))
{
var minTimestamp = DateTimeOffset.UtcNow;
// Act
var actual = tc.ExecuteCommand(
new[]
{
"-s", tc.ConnectionString,
"-c", tc.Container
},
tc.Content);
// Assert
var maxTimestamp = DateTimeOffset.UtcNow;
var result = await tc.VerifyContentAsync(actual, direct: true, latest: true);
var directFileName = result.DirectUri.ToString().Split('/').Last();
Assert.EndsWith(".txt", directFileName);
var unparsedTimestamp = directFileName.Substring(0, directFileName.Length - ".txt".Length);
var timestampLocal = DateTime.ParseExact(unparsedTimestamp, "yyyy.MM.dd.HH.mm.ss.fffffff", CultureInfo.InvariantCulture);
var timestamp = new DateTimeOffset(timestampLocal, TimeSpan.Zero);
Assert.True(timestamp >= minTimestamp, "The timestamp should be greater than or equal to the minimum.");
Assert.True(timestamp <= maxTimestamp, "The timestamp should be less than or equal to the maximum.");
Assert.EndsWith("/latest.txt", result.LatestUri.ToString());
}
}
示例6: AllowsBothDirectAndLatestUploadToBeDisabled
public async Task AllowsBothDirectAndLatestUploadToBeDisabled()
{
// Arrange
using (var tc = new TestContext(_output))
{
// Act
var actual = tc.ExecuteCommand(
new[]
{
"-s", tc.ConnectionString,
"-c", tc.Container,
"-f", tc.PathFormat,
"--no-direct",
"--no-latest"
},
tc.Content);
// Assert
await tc.VerifyContentAsync(actual, direct: false, latest: false);
}
}
示例7: CanSetContentTypeWithLongOptions
public async Task CanSetContentTypeWithLongOptions()
{
// Arrange
using (var tc = new TestContext(_output))
{
tc.Content = "{\"foo\": 5}";
tc.ContentType = "application/json";
// Act
var actual = tc.ExecuteCommand(
new[]
{
"--connection-string", tc.ConnectionString,
"--container", tc.Container,
"--path-format", tc.PathFormat,
"--content-type", tc.ContentType
},
tc.Content);
// Assert
await tc.VerifyContentAsync(actual, direct: true, latest: true);
}
}
示例8: CanUploadOnlyLatestWithUniqueOnlyOption
public async Task CanUploadOnlyLatestWithUniqueOnlyOption()
{
// Arrange
using (var tc = new TestContext(_output))
{
tc.Content = "something";
var initial = tc.ExecuteCommand(
new[]
{
"-s", tc.ConnectionString,
"-c", tc.Container,
"-f", tc.PathFormat,
"--no-direct"
},
tc.Content);
tc.Content = "something else";
// Act
var actual = tc.ExecuteCommand(
new[]
{
"--connection-string", tc.ConnectionString,
"--container", tc.Container,
"--path-format", tc.PathFormat,
"--no-direct",
"--only-unique"
},
tc.Content);
// Assert
await tc.VerifyContentAsync(actual, direct: false, latest: true);
Assert.Contains("Gettings the existing latest... different! The provided content will be uploaded.", actual.Output);
}
}
示例9: CanUploadOnlyWhenUniqueWithLongOptions
public void CanUploadOnlyWhenUniqueWithLongOptions()
{
// Arrange
using (var tc = new TestContext(_output))
{
var initial = tc.ExecuteCommand(
new[]
{
"-s", tc.ConnectionString,
"-c", tc.Container,
"-f", tc.PathFormat
},
tc.Content);
// Act
var actual = tc.ExecuteCommand(
new[]
{
"--connection-string", tc.ConnectionString,
"--container", tc.Container,
"--path-format", tc.PathFormat,
"--only-unique"
},
tc.Content);
// Assert
tc.VerifyCommandResult(actual);
Assert.Equal("Gettings the existing latest... exactly the same! No upload required.", actual.Output.TrimEnd());
}
}