本文整理汇总了C#中Mocks.VerifyWriteResponse方法的典型用法代码示例。如果您正苦于以下问题:C# Mocks.VerifyWriteResponse方法的具体用法?C# Mocks.VerifyWriteResponse怎么用?C# Mocks.VerifyWriteResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mocks
的用法示例。
在下文中一共展示了Mocks.VerifyWriteResponse方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Noop
public void Noop()
{
Mocks mocks = new Mocks();
NoopVerb verb = new NoopVerb();
verb.Process(mocks.Connection.Object, new SmtpCommand("NOOP"));
mocks.VerifyWriteResponse(StandardSmtpResponseCode.OK);
}
示例2: MessageAboveFixedSize
public void MessageAboveFixedSize()
{
Mocks mocks = new Mocks();
Message message = new Message(mocks.Session.Object);
mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(message);
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.ReadLine()).Returns(() => messageData[messageLine++]);
DataVerb verb = new DataVerb();
verb.Process(mocks.Connection.Object, new SmtpCommand("DATA"));
mocks.VerifyWriteResponse(StandardSmtpResponseCode.StartMailInputEndWithDot);
mocks.VerifyWriteResponse(StandardSmtpResponseCode.ExceededStorageAllocation);
}
示例3: SayHelo
public void SayHelo()
{
Mocks mocks = new Mocks();
HeloVerb verb = new HeloVerb();
verb.Process(mocks.Connection.Object, new SmtpCommand("HELO foo.blah"));
mocks.VerifyWriteResponse(StandardSmtpResponseCode.OK);
mocks.Session.VerifySet(s => s.ClientName, "foo.bar");
}
示例4: SayHeloTwice_ReturnsError
public void SayHeloTwice_ReturnsError()
{
Mocks mocks = new Mocks();
mocks.Session.SetupGet(s => s.ClientName).Returns("already.said.helo");
mocks.Session.SetupSet(s => s.ClientName).Never();
HeloVerb verb = new HeloVerb();
verb.Process(mocks.Connection.Object, new SmtpCommand("HELO foo.blah"));
mocks.VerifyWriteResponse(StandardSmtpResponseCode.BadSequenceOfCommands);
}
示例5: TestBadAddress
private void TestBadAddress(string address)
{
Mocks mocks = new Mocks();
Message message = new Message(mocks.Session.Object);
mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(message);
RcptToVerb verb = new RcptToVerb();
verb.Process(mocks.Connection.Object, new SmtpCommand("TO " + address));
mocks.VerifyWriteResponse(StandardSmtpResponseCode.SyntaxErrorInCommandArguments);
Assert.AreEqual(0, message.To.Length);
}
示例6: TestGoodAddress
private void TestGoodAddress(string address, string expectedAddress)
{
Mocks mocks = new Mocks();
Message message = new Message(mocks.Session.Object);
mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(message);
RcptToVerb verb = new RcptToVerb();
verb.Process(mocks.Connection.Object, new SmtpCommand("TO " + address));
mocks.VerifyWriteResponse(StandardSmtpResponseCode.OK);
Assert.AreEqual(expectedAddress, message.To[0]);
}
示例7: TestGoodData
private void TestGoodData(string[] messageData, string expectedData)
{
Mocks mocks = new Mocks();
Message message = new Message(mocks.Session.Object);
mocks.Connection.SetupGet(c => c.CurrentMessage).Returns(message);
mocks.ServerBehaviour.Setup(b => b.GetMaximumMessageSize(It.IsAny<IConnection>())).Returns((long?)null);
int messageLine = 0;
mocks.Connection.Setup(c => c.ReadLine()).Returns(() => messageData[messageLine++]);
DataVerb verb = new DataVerb();
verb.Process(mocks.Connection.Object, new SmtpCommand("DATA"));
mocks.VerifyWriteResponse(StandardSmtpResponseCode.StartMailInputEndWithDot);
mocks.VerifyWriteResponse(StandardSmtpResponseCode.OK);
using (StreamReader dataReader = new StreamReader(message.GetData(), Encoding.ASCII))
{
Assert.AreEqual(expectedData, dataReader.ReadToEnd());
}
}
示例8: Data_NoCurrentMessage_ReturnsError
public void Data_NoCurrentMessage_ReturnsError()
{
Mocks mocks = new Mocks();
DataVerb verb = new DataVerb();
verb.Process(mocks.Connection.Object, new SmtpCommand("DATA"));
mocks.VerifyWriteResponse(StandardSmtpResponseCode.BadSequenceOfCommands);
}