本文整理汇总了C#中TestContext.VerifyContentAsync方法的典型用法代码示例。如果您正苦于以下问题:C# TestContext.VerifyContentAsync方法的具体用法?C# TestContext.VerifyContentAsync怎么用?C# TestContext.VerifyContentAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestContext
的用法示例。
在下文中一共展示了TestContext.VerifyContentAsync方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UniqueClient_UpdatesUniqueWithoutExisting
public async Task UniqueClient_UpdatesUniqueWithoutExisting()
{
// Arrange
using (var tc = new TestContext())
{
// Act
var actual = await tc.Target.UploadAsync(tc.UniqueUploadRequest);
// Assert
await tc.VerifyContentAsync(actual.DirectUri);
await tc.VerifyContentAsync(actual.LatestUri);
}
}
示例2: UniqueClient_UpdatesUniqueWithExisting
public async Task UniqueClient_UpdatesUniqueWithExisting()
{
// Arrange
using (var tc = new TestContext())
{
tc.UniqueUploadRequest.Stream = new MemoryStream(Encoding.UTF8.GetBytes("oldContent"));
await tc.Target.UploadAsync(tc.UniqueUploadRequest);
tc.UtcNow = tc.UtcNow.AddMinutes(1);
tc.UniqueUploadRequest.Stream = new MemoryStream(Encoding.UTF8.GetBytes(tc.Content));
// Act
var actual = await tc.Target.UploadAsync(tc.UniqueUploadRequest);
// Assert
await tc.VerifyContentAsync(actual.DirectUri);
await tc.VerifyContentAsync(actual.LatestUri);
}
}
示例3: UniqueClient_DoesNotOverwriteDirectTimestamp
public async Task UniqueClient_DoesNotOverwriteDirectTimestamp()
{
// Arrange
using (var tc = new TestContext())
{
tc.UniqueUploadRequest.Type = UploadRequestType.Timestamp;
tc.Content = "content";
tc.UniqueUploadRequest.Stream = new MemoryStream(Encoding.UTF8.GetBytes(tc.Content));
var uploadResult = await tc.Target.UploadAsync(tc.UniqueUploadRequest);
tc.Content = "newerContent";
tc.UniqueUploadRequest.Stream = new MemoryStream(Encoding.UTF8.GetBytes(tc.Content));
// Act & Assert
var exception = await Assert.ThrowsAsync<StorageException>(() => tc.Target.UploadAsync(tc.UniqueUploadRequest));
Assert.Equal(409, exception.RequestInformation.HttpStatusCode);
await tc.VerifyContentAsync(uploadResult.DirectUri, "content");
await tc.VerifyContentAsync(uploadResult.LatestUri, "content");
}
}
示例4: 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);
}
}
示例5: Client_DoesNotOverwriteExistingDirectBlob
public async Task Client_DoesNotOverwriteExistingDirectBlob()
{
// Arrange
using (var tc = new TestContext())
{
tc.Content = "[1, 2]";
tc.UploadRequest.ContentType = "application/json";
tc.UploadRequest.Stream = new MemoryStream(Encoding.UTF8.GetBytes(tc.Content));
var uploadResult = await tc.Target.UploadAsync(tc.UploadRequest);
tc.UploadRequest.ContentType = "text/plain";
tc.UploadRequest.Stream = new MemoryStream(Encoding.UTF8.GetBytes("foobar"));
tc.UploadRequest.ETag = uploadResult.LatestETag;
// Act & Assert
var exception = await Assert.ThrowsAsync<StorageException>(() => tc.Target.UploadAsync(tc.UploadRequest));
Assert.Equal(409, exception.RequestInformation.HttpStatusCode);
tc.UploadRequest.ContentType = "application/json";
await tc.VerifyContentAsync(uploadResult.LatestUri);
}
}
示例6: 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());
}
}
示例7: 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);
}
}
示例8: 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);
}
}
示例9: 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);
}
}
示例10: UniqueClient_AllowsNullEqualsAsync
public async Task UniqueClient_AllowsNullEqualsAsync()
{
// Arrange
using (var tc = new TestContext())
{
tc.Content = "a1";
tc.UniqueUploadRequest.Stream = new MemoryStream(Encoding.UTF8.GetBytes(tc.Content));
await tc.Target.UploadAsync(tc.UniqueUploadRequest);
tc.UtcNow = tc.UtcNow.AddMinutes(1);
tc.Content = "a2";
tc.UniqueUploadRequest.Stream = new MemoryStream(Encoding.UTF8.GetBytes(tc.Content));
tc.UniqueUploadRequest.EqualsAsync = null;
// Act
var actual = await tc.Target.UploadAsync(tc.UniqueUploadRequest);
// Assert
await tc.VerifyContentAsync(actual.DirectUri);
await tc.VerifyContentAsync(actual.LatestUri);
}
}