当前位置: 首页>>代码示例>>C#>>正文


C# StreamReader.ShouldEqual方法代码示例

本文整理汇总了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>");
            }
        }
开发者ID:robitar,项目名称:postal,代码行数:31,代码来源:EmailParserTests.cs

示例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}");
 }
开发者ID:Zocdoc,项目名称:cassette,代码行数:12,代码来源:CombinedStylesheetBundle.cs

示例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);
        }
开发者ID:KMASubhani,项目名称:WebAPIContrib,代码行数:17,代码来源:PlainTextFormatterTests.cs

示例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);
            }
        }
开发者ID:nathanpalmer,项目名称:Nancy,代码行数:20,代码来源:NancyWcfGenericServiceFixture.cs

示例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""}");
 }
开发者ID:AndyHitchman,项目名称:Stash,代码行数:5,代码来源:when_serializing_aggregates_to_json.cs

示例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);
        }
开发者ID:rmueller,项目名称:WebAPIContrib,代码行数:22,代码来源:ServiceStackTextFormatterTests.cs

示例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""}");
 }
开发者ID:AndyHitchman,项目名称:Stash,代码行数:5,代码来源:when_serializing_to_json_ignoring_aggregates.cs


注:本文中的System.IO.StreamReader.ShouldEqual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。