本文整理汇总了C#中System.IO.StreamReader.ShouldEqual方法的典型用法代码示例。如果您正苦于以下问题:C# StreamReader.ShouldEqual方法的具体用法?C# StreamReader.ShouldEqual怎么用?C# StreamReader.ShouldEqual使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.StreamReader
的用法示例。
在下文中一共展示了StreamReader.ShouldEqual方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Alternative_views_are_added_to_MailMessage
public void Alternative_views_are_added_to_MailMessage()
{
var input = @"
To: [email protected]
From: [email protected]
Subject: Test Subject
Views: Text, Html";
var text = @"Content-Type: text/plain
Hello, World!";
var html = @"Content-Type: text/html
<p>Hello, World!</p>";
var email = new Email("Test");
var renderer = new Mock<IEmailViewRenderer>();
renderer.Setup(r => r.Render(email, "Test.Text")).Returns(text);
renderer.Setup(r => r.Render(email, "Test.Html")).Returns(html);
var parser = new EmailParser(renderer.Object);
using (var message = parser.Parse(input, email))
{
message.AlternateViews[0].ContentType.ShouldEqual(new ContentType("text/plain; charset=utf-16"));
var textContent = new StreamReader(message.AlternateViews[0].ContentStream).ReadToEnd();
textContent.ShouldEqual("Hello, World!");
message.AlternateViews[1].ContentType.ShouldEqual(new ContentType("text/html; charset=utf-16"));
var htmlContent = new StreamReader(message.AlternateViews[1].ContentStream).ReadToEnd();
htmlContent.ShouldEqual("<p>Hello, World!</p>");
}
}
示例2: GivenCombinedStyleSheetBundle_WhenRenderedAndMinified_ThenCssIsProperlyMinifiedAsCssAndNotJavascript
public void GivenCombinedStyleSheetBundle_WhenRenderedAndMinified_ThenCssIsProperlyMinifiedAsCssAndNotJavascript()
{
CassetteSettings settings = new CassetteSettings("1");
IBundleProcessor<StylesheetBundle> processor = new StylesheetPipeline();
underTest.Processor = processor;
inner.Processor = processor;
underTest.Process(settings);
// underTest.Renderer = new StylesheetHtmlRenderer(new UrlGenerator(new UrlPlaceholderWrapper(), ""));
var cssContent = underTest.OpenStream();
string output = new StreamReader(cssContent).ReadToEnd();
output.ShouldEqual(".className{display:none}");
}
示例3: Should_write_string_to_stream
public void Should_write_string_to_stream()
{
var formatter = new PlainTextFormatter();
var content = new StringContent(string.Empty);
content.Headers.Clear();
var memoryStream = new MemoryStream();
var value = "Hello World";
var resultTask = formatter.WriteToStreamAsync(typeof(string), value, memoryStream, content, transportContext: null);
resultTask.Wait();
memoryStream.Position = 0;
string serializedString = new StreamReader(memoryStream).ReadToEnd();
serializedString.ShouldEqual(value);
}
示例4: Should_be_able_to_post_body_to_selfhost
public void Should_be_able_to_post_body_to_selfhost()
{
using (CreateAndOpenWebServiceHost())
{
const string testBody = "This is the body of the request";
var request =
WebRequest.Create(new Uri(BaseUri, "rel"));
request.Method = "POST";
var writer =
new StreamWriter(request.GetRequestStream()) {AutoFlush = true};
writer.Write(testBody);
var responseBody =
new StreamReader(request.GetResponse().GetResponseStream()).ReadToEnd();
responseBody.ShouldEqual(testBody);
}
}
示例5: Should_write_serialized_object_to_stream_using_date_handler
public void Should_write_serialized_object_to_stream_using_date_handler()
{
var formatter = new ServiceStackTextFormatter(JsonDateHandler.TimestampOffset);
var value = GetTestObject();
var content = new StringContent(string.Empty);
var memoryStream = new MemoryStream();
var resultTask = formatter.WriteToStreamAsync(typeof(RootClass), value, memoryStream, content, transportContext: null);
resultTask.Wait();
memoryStream.Position = 0;
string serializedString = new StreamReader(memoryStream).ReadToEnd();
JsConfig.DateHandler = JsonDateHandler.TimestampOffset;
var expected = value.ToJson();
JsConfig.Reset();
serializedString.ShouldEqual(expected);
}
开发者ID:panesofglass,项目名称:WebApiContrib.Formatting.ServiceStack,代码行数:20,代码来源:ServiceStackTextFormatterTests.cs
示例6: Should_write_serialized_object_to_stream
public void Should_write_serialized_object_to_stream()
{
var formatter = new ServiceStackTextFormatter();
var value = GetTestObject();
var content = new StringContent(string.Empty);
var memoryStream = new MemoryStream();
var resultTask = formatter.WriteToStreamAsync(typeof(RootClass), value, memoryStream, content, transportContext: null);
resultTask.Wait();
memoryStream.Position = 0;
string serializedString = new StreamReader(memoryStream).ReadToEnd();
// Formatter uses ISO8601 dates by default
using (var scope = JsConfig.BeginScope())
{
scope.DateHandler = JsonDateHandler.ISO8601;
var expextedResult = value.ToJson();
serializedString.ShouldEqual(expextedResult);
}
}
开发者ID:WebApiContrib,项目名称:WebApiContrib.Formatting.ServiceStack,代码行数:23,代码来源:ServiceStackTextFormatterTests.cs
示例7: it_should_create_a_json_document_referencing_the_registered_graph_by_internal_id
public void it_should_create_a_json_document_referencing_the_registered_graph_by_internal_id()
{
var doc = new StreamReader(actual).ReadToEnd();
doc.ShouldEqual(@"{""Composed"":{""__StashInternalId"":""" + expectedInternalId + @"""},""AnotherComposed"":null,""AnotherProperty"":""another property""}");
}
示例8: Should_write_serialized_object_to_stream
public void Should_write_serialized_object_to_stream()
{
var formatter = new ServiceStackTextFormatter();
var value = GetTestObject();
var contentHeader = new StringContent(string.Empty).Headers;
contentHeader.Clear();
var memoryStream = new MemoryStream();
var resultTask = formatter.WriteToStreamAsync(typeof(RootClass), value, memoryStream, contentHeader, new FormatterContext(StandardMediaTypeHeaderValues.ApplicationJson, isRead: false), transportContext: null);
resultTask.Wait();
memoryStream.Position = 0;
string serializedString = new StreamReader(memoryStream).ReadToEnd();
// Formatter uses ISO8601 dates by default
JsConfig.DateHandler = JsonDateHandler.ISO8601;
var expextedResult = value.ToJson();
JsConfig.Reset();
serializedString.ShouldEqual(expextedResult);
}
示例9: it_should_create_a_json_document
public void it_should_create_a_json_document()
{
var doc = new StreamReader(actual).ReadToEnd();
doc.ShouldEqual(@"{""AProperty"":""test property""}");
}