Exemplo n.º 1
0
        public void WhenNotEqual()
        {
            var expectedCode = @"
namespace RoslynSandbox
{
    class Foo
    {
        private readonly int _value;
    }
}";

            var actualCode = @"
namespace RoslynSandbox
{
    class Foo
    {
        private readonly int bar;
    }
}";
            var exception  = Assert.Throws <AssertException>(() => TextAssert.AreEqual(expectedCode, actualCode));
            var expected   = "Mismatch on line 6\r\n" +
                             "Expected:         private readonly int _value;\r\n" +
                             "Actual:           private readonly int bar;\r\n" +
                             "                                       ^\r\n";

            Assert.AreEqual(expected, exception.Message);
        }
Exemplo n.º 2
0
        public void NestedClasses()
        {
            string code = @"using System;

//test
[Description(""Test"")]
class ScriptA
{
    int Count;
    int fieldI;
    int prop {get;set;}
    void main0() {}
    void main1(int test) {}
    void main2(int test, int test2) {}

    class Printer
    {
        void Print(int test) {}
        string Name {get;set;}

        class Settings
        {
            void Print(int test) {}
            string Name {get;set;}
        }
    }
}

class ScriptB
{
    int CountB;
    int fieldIB;
    int propB {get;set;}
    void main0() {}
    void main1B(int test) {}
    void main2B(int test, int test2) {}
}";

            var map = Reflector.GetMapOf(code).OrderBy(x => x.ParentDisplayName)
                      .Select(x => string.Format("{0}.{1}: Line {2}", x.ParentDisplayName, x.DisplayName, x.Line))
                      .ToArray();

            string mapDisplay = string.Join(Environment.NewLine, map);

            TextAssert.Equal(mapDisplay,
                             @"ScriptA.prop: Line 9
ScriptA.main0(): Line 10
ScriptA.main1(): Line 11
ScriptA.main2(,): Line 12
ScriptA.Printer.Print(): Line 16
ScriptA.Printer.Name: Line 17
ScriptA.Printer.Settings.Print(): Line 21
ScriptA.Printer.Settings.Name: Line 22
ScriptB.propB: Line 31
ScriptB.main0(): Line 32
ScriptB.main1B(): Line 33
ScriptB.main2B(,): Line 34");
        }
Exemplo n.º 3
0
        public void Text_encoding()
        {
            const string expectedDocumentContent = "Äöåõ";
            var          html = string.Format(HtmlDocumentFormat, expectedDocumentContent);

            var result = Pdf.From(html).EncodedWith("utf-8").Content();

            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(result));
        }
Exemplo n.º 4
0
        public void Pdf_document_content()
        {
            const string expectedDocumentContent = "Expected document content";
            var          html = string.Format(HtmlDocumentFormat, expectedDocumentContent);

            var result = Pdf.From(html).Content();

            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(result));
        }
Exemplo n.º 5
0
        public void Margins()
        {
            const string expectedDocumentContent = "Expected document content";

            var html = string.Format(HtmlDocumentFormat, expectedDocumentContent);

            var result = Pdf.From(html).WithMargins(1.25.Centimeters()).Content();

            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(result));
        }
Exemplo n.º 6
0
        public void Is_directory_agnostic()
        {
            const string expectedDocumentContent = "Expected document content";
            var          html = string.Format(HtmlDocumentFormat, expectedDocumentContent);

            Directory.SetCurrentDirectory(@"c:\");
            var result = Pdf.From(html).Content();

            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(result));
        }
Exemplo n.º 7
0
        public void Page_size()
        {
            const string expectedDocumentContent = "Expected document content";
            var          html = string.Format(HtmlDocumentFormat, expectedDocumentContent);

            var result = Pdf.From(html).OfSize(PaperSize.A4).Content();

            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(result));
            Assert.AreEqual(596, PdfDocumentReader.WidthOfFirstPage(result));
            Assert.AreEqual(_297mmInPostScriptPoints, PdfDocumentReader.HeightOfFirstPage(result));
        }
Exemplo n.º 8
0
        public void Document_title()
        {
            const string expectedTitle           = "Expected title";
            const string expectedDocumentContent = "Expected document content";
            var          html = string.Format(HtmlDocumentFormat, expectedDocumentContent);

            var result = Pdf.From(html).WithTitle(expectedTitle).Content();

            Assert.AreEqual(expectedTitle, PdfDocumentReader.Title(result));
            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(result));
        }
Exemplo n.º 9
0
        public void Convert_multiple_documents_sequently()
        {
            const string expectedDocumentContent = "Expected document content";
            var          html = string.Format(HtmlDocumentFormat, expectedDocumentContent);

            var first  = Pdf.From(html).Content();
            var second = Pdf.From(html).Content();
            var third  = Pdf.From(html).Content();

            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(first));
            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(second));
            TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(third));
        }
Exemplo n.º 10
0
        public void Parsing_3()
        {
            var template =
                @"for (int $i$ = 0; $i$ < $length$; $i$++)
{
    $|$
}";
            var expected =
                @"for (int i = 0; i < length; i++)
    {
        |
    }";

            var result = CSScriptIntellisense.Snippets.PrepareForIncertion(template, 4);

            TextAssert.Equal(expected, result.ReplacementString);
        }
Exemplo n.º 11
0
        public void Convert_massive_number_of_documents()
        {
            const string expectedDocumentContent = "Expected document content";
            const int    documentCount           = 100;
            var          html  = string.Format(HtmlDocumentFormat, expectedDocumentContent);
            var          tasks = new List <Task <byte[]> >();

            for (var i = 0; i < documentCount; i++)
            {
                tasks.Add(Task.Run(() => Pdf.From(html).Content()));
            }

            Task.WaitAll(tasks.OfType <Task>().ToArray());

            foreach (var task in tasks)
            {
                TextAssert.AreEqual(expectedDocumentContent, PdfDocumentReader.ToText(task.Result));
            }
        }
Exemplo n.º 12
0
        public void WhenEqual()
        {
            var expected = @"
namespace RoslynSandbox
{
    class Foo
    {
        private readonly int _value;
    }
}";

            var actual = @"
namespace RoslynSandbox
{
    class Foo
    {
        private readonly int _value;
    }
}";

            TextAssert.AreEqual(expected, actual);
        }
Exemplo n.º 13
0
        public static void WhenEqual()
        {
            var expected = @"
namespace N
{
    class C
    {
        private readonly int _value;
    }
}";

            var actual = @"
namespace N
{
    class C
    {
        private readonly int _value;
    }
}";

            TextAssert.AreEqual(expected, actual);
        }
Exemplo n.º 14
0
        public void Query_ValidQueryClassWithFields_ResultNoFieldsBind()
        {
            var target = CreateClientAndAuth();

            // Public FIELDS are supported.
            var actual1 = target.Query <ContactStubWithFields>("SELECT Id, Name, Email FROM Contact LIMIT 1 OFFSET 0");

            Assert.AreEqual(1, actual1.Count);

            var first1 = actual1 [0];

            TextAssert.IsNotNullOrEmpty(first1.Id);
            TextAssert.IsNotNullOrEmpty(first1.Name);

            // Public PROPERTIES are supported.
            var actual2 = target.Query <ContactStub>("SELECT Id, Name, Email FROM Contact LIMIT 1 OFFSET 0");

            Assert.AreEqual(1, actual2.Count);

            var first2 = actual2 [0];

            TextAssert.IsNotNullOrEmpty(first2.Id);
            TextAssert.IsNotNullOrEmpty(first2.Name);
        }