Esempio n. 1
0
        public void NullArguments()
        {
            var type        = GetType();
            var assembly    = type.GetAssembly();
            var stream      = Stream.Null;
            var dataContext = new object();
            var document    = new Document();
            var target      = new TextRenderTarget();
            var buffer      = new ConsoleBuffer(80);
            var renderRect  = Rect.Empty;

          #if XAML
            var resourceName = "";

            new Action(() => ConsoleRenderer.ReadElementFromStream <Br>(null, dataContext))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(stream));
            new Action(() => ConsoleRenderer.ReadElementFromResource <Br>((Assembly)null, resourceName, dataContext))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(assembly));
            new Action(() => ConsoleRenderer.ReadElementFromResource <Br>(assembly, null, dataContext))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(resourceName));
            new Action(() => ConsoleRenderer.ReadElementFromResource <Br>((Type)null, resourceName, dataContext))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(type));
            new Action(() => ConsoleRenderer.ReadElementFromResource <Br>(type, null, dataContext))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(resourceName));
            new Action(() => ConsoleRenderer.ReadDocumentFromStream(null, dataContext))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(stream));
            new Action(() => ConsoleRenderer.ReadDocumentFromResource((Assembly)null, resourceName, dataContext))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(assembly));
            new Action(() => ConsoleRenderer.ReadDocumentFromResource(assembly, null, dataContext))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(resourceName));
            new Action(() => ConsoleRenderer.ReadDocumentFromResource((Type)null, resourceName, dataContext))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(type));
            new Action(() => ConsoleRenderer.ReadDocumentFromResource(type, null, dataContext))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(resourceName));
          #endif
            new Action(() => ConsoleRenderer.RenderDocument(null))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(document));
            new Action(() => ConsoleRenderer.RenderDocumentToBuffer(null, buffer, renderRect))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(document));
            new Action(() => ConsoleRenderer.RenderDocumentToBuffer(document, null, renderRect))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(buffer));
            new Action(() => ConsoleRenderer.RenderDocumentToText(null, target))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(document));
            new Action(() => ConsoleRenderer.RenderDocumentToText(document, null))
            .Should().Throw <ArgumentNullException>().Which.ParamName.Should().Be(nameof(target));
        }
        public void ReadElementFromStreamWithContext()
        {
            Span span = ConsoleRenderer.ReadElementFromStream <Span>(StringToStream($"<Span {XamlNS} Text='{{Get Length}}'/>"), "abc");

            span.Text.Should().Be("3");
        }
        public void ReadElementFromStream()
        {
            Span span = ConsoleRenderer.ReadElementFromStream <Span>(StringToStream($"<Span {XamlNS} Text='Foo'/>"), null);

            span.Text.Should().Be("Foo");
        }