本文整理汇总了C#中Mocks.VerifyWriteResponseAsync方法的典型用法代码示例。如果您正苦于以下问题:C# Mocks.VerifyWriteResponseAsync方法的具体用法?C# Mocks.VerifyWriteResponseAsync怎么用?C# Mocks.VerifyWriteResponseAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mocks
的用法示例。
在下文中一共展示了Mocks.VerifyWriteResponseAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestGoodDataAsync
private async Task TestGoodDataAsync(string[] messageData, string expectedData, bool eightBitClean)
{
Mocks mocks = new Mocks();
if (eightBitClean)
{
mocks.Connection.SetupGet(c => c.ReaderEncoding).Returns(Encoding.UTF8);
}
MemoryMessage.Builder messageBuilder = new MemoryMessage.Builder();
mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);
mocks.ServerBehaviour.Setup(b => b.GetMaximumMessageSize(It.IsAny<IConnection>())).Returns((long?)null);
int messageLine = 0;
mocks.Connection.Setup(c => c.ReadLineAsync()).Returns(() => Task.FromResult(messageData[messageLine++]));
DataVerb verb = new DataVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("DATA"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.StartMailInputEndWithDot);
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
using (StreamReader dataReader = new StreamReader(messageBuilder.GetData(), eightBitClean ? Encoding.UTF8 : new ASCIISevenBitTruncatingEncoding()))
{
Assert.Equal(expectedData, dataReader.ReadToEnd());
}
}
示例2: Noop
public async Task Noop()
{
Mocks mocks = new Mocks();
NoopVerb verb = new NoopVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("NOOP"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
}
示例3: Process_NoArguments_Accepted
public async Task Process_NoArguments_Accepted()
{
Mocks mocks = new Mocks();
EhloVerb ehloVerb = new EhloVerb();
await ehloVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("EHLO"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
mocks.Session.VerifySet(s => s.ClientName = "");
}
示例4: Quit_RespondsWithClosingChannel
public async Task Quit_RespondsWithClosingChannel()
{
Mocks mocks = new Mocks();
QuitVerb quitVerb = new QuitVerb();
await quitVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("QUIT"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.ClosingTransmissionChannel);
}
示例5: Data_AboveSizeLimit_Rejected
public async Task Data_AboveSizeLimit_Rejected()
{
Mocks mocks = new Mocks();
MemoryMessage.Builder messageBuilder = new MemoryMessage.Builder();
mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);
mocks.ServerBehaviour.Setup(b => b.GetMaximumMessageSize(It.IsAny<IConnection>())).Returns(10);
string[] messageData = new string[] { new string('x', 11), "." };
int messageLine = 0;
mocks.Connection.Setup(c => c.ReadLineAsync()).Returns(() => Task.FromResult(messageData[messageLine++]));
DataVerb verb = new DataVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("DATA"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.StartMailInputEndWithDot);
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.ExceededStorageAllocation);
}
示例6: ProcessAsync
public async Task ProcessAsync()
{
Mocks mocks = new Mocks();
RsetVerb verb = new RsetVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("RSET"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
mocks.Connection.Verify(c => c.AbortMessage());
}
示例7: NoCertificateAvailable_ReturnsErrorResponse
public async Task NoCertificateAvailable_ReturnsErrorResponse()
{
Mocks mocks = new Mocks();
mocks.ServerBehaviour.Setup(b => b.GetSSLCertificate(It.IsAny<IConnection>())).Returns<X509Certificate>(null);
StartTlsVerb verb = new StartTlsVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("STARTTLS"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.CommandNotImplemented);
}
示例8: ProcessAsync_UnregisteredSubCommand_ErrorResponse
public async Task ProcessAsync_UnregisteredSubCommand_ErrorResponse()
{
Mocks mocks = new Mocks();
Mock<VerbWithSubCommands> verbWithSubCommands = new Mock<VerbWithSubCommands>() { CallBase = true };
await verbWithSubCommands.Object.ProcessAsync(mocks.Connection.Object, new SmtpCommand("VERB SUBCOMMAND1"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.CommandParameterNotImplemented);
}
示例9: SayHelo
public async Task SayHelo()
{
Mocks mocks = new Mocks();
HeloVerb verb = new HeloVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("HELO foo.blah"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
mocks.Session.VerifySet(s => s.ClientName = "foo.blah");
}
示例10: SayHeloTwice_ReturnsError
public async Task SayHeloTwice_ReturnsError()
{
Mocks mocks = new Mocks();
mocks.Session.SetupGet(s => s.ClientName).Returns("already.said.helo");
HeloVerb verb = new HeloVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("HELO foo.blah"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.BadSequenceOfCommands);
}
示例11: TestBadAddressAsync
private async Task TestBadAddressAsync(string address)
{
Mocks mocks = new Mocks();
MemoryMessage.Builder messageBuilder = new MemoryMessage.Builder();
mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);
RcptToVerb verb = new RcptToVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("TO " + address));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.SyntaxErrorInCommandArguments);
Assert.Equal(0, messageBuilder.To.Count);
}
示例12: TestGoodAddressAsync
private async Task TestGoodAddressAsync(string address, string expectedAddress)
{
Mocks mocks = new Mocks();
MemoryMessage.Builder messageBuilder = new MemoryMessage.Builder();
mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(messageBuilder);
RcptToVerb verb = new RcptToVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("TO " + address));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
Assert.Equal(expectedAddress, messageBuilder.To.First());
}
示例13: Process_RespondsWith250
public async Task Process_RespondsWith250()
{
Mocks mocks = new Mocks();
Mock<IExtensionProcessor> mockExtensionProcessor1 = new Mock<IExtensionProcessor>();
mockExtensionProcessor1.SetupGet(ep => ep.EHLOKeywords).Returns(new[] { "EXTN1" });
Mock<IExtensionProcessor> mockExtensionProcessor2 = new Mock<IExtensionProcessor>();
mockExtensionProcessor2.SetupGet(ep => ep.EHLOKeywords).Returns(new[] { "EXTN2A", "EXTN2B" });
mocks.Connection.SetupGet(c => c.ExtensionProcessors).Returns(new[]
{
mockExtensionProcessor1.Object,
mockExtensionProcessor2.Object
});
EhloVerb ehloVerb = new EhloVerb();
await ehloVerb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("EHLO foobar"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
}
示例14: Process_SaidHeloAlready_Allowed
public async Task Process_SaidHeloAlready_Allowed()
{
Mocks mocks = new Mocks();
EhloVerb verb = new EhloVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("EHLO foo.blah"));
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("EHLO foo.blah"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.OK);
}
示例15: Data_NoCurrentMessage_ReturnsError
public async Task Data_NoCurrentMessage_ReturnsError()
{
Mocks mocks = new Mocks();
DataVerb verb = new DataVerb();
await verb.ProcessAsync(mocks.Connection.Object, new SmtpCommand("DATA"));
mocks.VerifyWriteResponseAsync(StandardSmtpResponseCode.BadSequenceOfCommands);
}