本文整理汇总了C#中TestContext.Expect方法的典型用法代码示例。如果您正苦于以下问题:C# TestContext.Expect方法的具体用法?C# TestContext.Expect怎么用?C# TestContext.Expect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestContext
的用法示例。
在下文中一共展示了TestContext.Expect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnRun
protected override void OnRun (TestContext ctx, CancellationToken cancellationToken)
{
if (Parameters.ExpectedCipher != null) {
ctx.Assert (Client.SupportsConnectionInfo, "client supports connection info");
ctx.Assert (Server.SupportsConnectionInfo, "server supports connection info");
var clientInfo = Client.GetConnectionInfo ();
var serverInfo = Server.GetConnectionInfo ();
if (ctx.Expect (clientInfo, Is.Not.Null, "client connection info"))
ctx.Expect (clientInfo.CipherCode, Is.EqualTo (Parameters.ExpectedCipher.Value), "client cipher");
if (ctx.Expect (serverInfo, Is.Not.Null, "server connection info"))
ctx.Expect (serverInfo.CipherCode, Is.EqualTo (Parameters.ExpectedCipher.Value), "server cipher");
}
if (Parameters.ProtocolVersion != null) {
ctx.Expect (Client.ProtocolVersion, Is.EqualTo (Parameters.ProtocolVersion), "client protocol version");
ctx.Expect (Server.ProtocolVersion, Is.EqualTo (Parameters.ProtocolVersion), "server protocol version");
}
if (Server.Provider.SupportsSslStreams && (Parameters.ServerFlags & ServerFlags.RequireClientCertificate) != 0) {
ctx.Expect (Server.SslStream.HasRemoteCertificate, "has remote certificate");
ctx.Expect (Server.SslStream.IsMutuallyAuthenticated, "is mutually authenticated");
}
base.OnRun (ctx, cancellationToken);
}
示例2: ExpectBlob
protected async Task ExpectBlob (TestContext ctx, ICommonConnection connection, HandshakeInstrumentType type, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested ();
LogDebug (ctx, 2, "ExpectBlob", connection, type);
var buffer = new byte [4096];
var blob = Instrumentation.GetTextBuffer (type);
var ret = await connection.Stream.ReadAsync (buffer, 0, buffer.Length, cancellationToken);
LogDebug (ctx, 2, "ExpectBlob #1", connection, type, ret);
if (ctx.Expect (ret, Is.GreaterThan (0), "read success")) {
var result = new BufferOffsetSize (buffer, 0, ret);
ctx.Expect (result, new IsEqualBlob (blob), "blob");
}
LogDebug (ctx, 2, "ExpectBlob done", connection, type);
}