本文整理汇总了C#中System.IO.StreamReader.EndsWith方法的典型用法代码示例。如果您正苦于以下问题:C# StreamReader.EndsWith方法的具体用法?C# StreamReader.EndsWith怎么用?C# StreamReader.EndsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StreamReader
的用法示例。
在下文中一共展示了StreamReader.EndsWith方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DebugConsoleOnReceivedTests
public async Task DebugConsoleOnReceivedTests(bool connect)
{
// Setup
var env = new Mock<IEnvironment>();
var tracer = new Mock<ITracer>();
var settings = new Mock<IDeploymentSettingsManager>();
var process = new Mock<IProcess>();
var connectionId = Guid.NewGuid().ToString();
var data = Guid.NewGuid().ToString() + "\n";
var mem = new MemoryStream();
using (var controller = new PersistentCommandTest(env.Object, settings.Object, tracer.Object, process.Object))
{
// Setup
process.SetupGet(p => p.StandardInput)
.Returns(new StreamWriter(mem));
// Test
if (connect)
{
await controller.Connect(Mock.Of<IRequest>(), connectionId);
}
await controller.Receive(Mock.Of<IRequest>(), connectionId, data);
// Assert
Assert.Equal(1, PersistentCommandTest.ProcessCount);
if (connect)
{
Assert.True(mem.Position > 0, "must write data");
mem.Position = 0;
var result = new StreamReader(mem).ReadToEnd();
Assert.True(result.EndsWith("\n"));
Assert.Equal(data, result);
}
else
{
Assert.True(mem.Position == 0, "must skip data");
}
}
}
示例2: WhiteSpaceShouldBeIncludedWhenRequired
public void WhiteSpaceShouldBeIncludedWhenRequired()
{
var mockSender = A.Fake<IMailSender>();
var attribute = new SmtpMailAttributes();
var mailer = new TestMailerBase(attribute, mockSender);
var email = mailer.Email("WhitespaceTrimTest", false);
var body = new StreamReader(email.Mail.AlternateViews[0].ContentStream).ReadToEnd();
Assert.True(body.StartsWith(Environment.NewLine));
Assert.True(body.EndsWith(Environment.NewLine));
}