Esempio n. 1
0
            public void TestCorrectJson()
            {
                string data = @"[
    { 'Name':'Andrei Ignat', 
        'WebSite':'http://msprogrammer.serviciipeweb.ro/',
        'CV':'http://serviciipeweb.ro/iafblog/content/binary/cv.doc'        
    },
{ 'Name':'Your Name', 
        'WebSite':'http://your website',
        'CV':'cv.doc'        
    }
]";
                

                var p = new Person { Name = "Andrei Ignat", WebSite = "http://msprogrammer.serviciipeweb.ro/", CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" };
                var byte1 = new ExportExcel2007<Person>().ExportResult(new List<Person>(){p,p});

                var byte2 = ExportFactory.ExportDataJson(data, ExportToFormat.Excel2007);

                //File.WriteAllBytes("byte1.xlsx",byte1);
                //File.WriteAllBytes("byte2.xlsx", byte2);
                Assert.IsTrue(Math.Abs(byte1.Length-byte2.Length)<100);


            }
            public void TestConstructorItemWithPerson()
            {
                var t = new Person {Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/"};
                var export = new ExportWord2003<Person>();
                Assert.AreEqual(@"<w:tr>
   <w:tc>
    <w:p>
        <w:r>
            <w:t>@Model.Name</w:t>
        </w:r>
    </w:p>
    </w:tc>
   <w:tc>
    <w:p>
        <w:r>
            <w:t>@Model.WebSite</w:t>
        </w:r>
    </w:p>
    </w:tc>
   <w:tc>
    <w:p>
        <w:r>
            <w:t>@Model.CV</w:t>
        </w:r>
    </w:p>
    </w:tc>
</w:tr>", export.ExportItem);
            }
            public void TestConstructorItemWithPerson()
            {
                var t = new Person {Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/"};
                var export = new ExportExcel2007<Person>();
                Assert.AreEqual(@"<row>
   <c t='inlineStr'>
                <is>
                    <t>@Model.Name
                    </t>
                </is>
    </c>
   <c t='inlineStr'>
                <is>
                    <t>@Model.WebSite
                    </t>
                </is>
    </c>
   <c t='inlineStr'>
                <is>
                    <t>@Model.CV
                    </t>
                </is>
    </c>
</row>", export.ExportItem);
            }
 public void TestWithPersonHeader()
 {
     var p = new Person {Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/"};
     var export = new ExportPdfiTextSharp4<Person>();
     var data = export.ExportResultStringPart(new List<Person>() {p});
     var str = data;
     Assert.IsTrue(str.Contains(export.ExportHeader),"must contain the header");
 }
 public void TestWithPersonHeader()
 {
     var p = new Person {Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/"};
     var export = new ExportExcel2003<Person>();
     var data = export.ExportResult(new List<Person>() {p});
     var str = Encoding.Unicode.GetString(data);
     Assert.IsTrue(str.Contains(export.ExportHeader),"must contain the header");
 }
            public void TestWithPersonData()
            {
                var p = new Person { Name = "Andrei Ignat", WebSite = "http://msprogrammer.serviciipeweb.ro/", CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" };
                var export = new ExportPdfiTextSharp4< Person >();
                var data = export.ExportResultStringPart(new List<Person>() { p});
                var str = data;
                Assert.IsTrue(str.Contains("http://serviciipeweb.ro/iafblog/content/binary/cv.doc"),"must contain the cv");

            }
            public void TestWithPersonData()
            {
                var p = new Person { Name = "Andrei Ignat", WebSite = "http://msprogrammer.serviciipeweb.ro/", CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" };
                var export = new ExportExcel2003<Person>();
                var data = export.ExportResult(new List<Person>() { p});
                var str = Encoding.Unicode.GetString(data);
                Assert.IsTrue(str.Contains("http://serviciipeweb.ro/iafblog/content/binary/cv.doc"),"must contain the cv");

            }
            //[TestMethod]
            public void TestPDFiTextSharp()
            {
                var p = new Person { Name = "Andrei Ignat", WebSite = "http://msprogrammer.serviciipeweb.ro/", CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" };
                var export = new ExportPdfiTextSharp4< Person >();
                var data = export.ExportResult(new List<Person>() { p });
                //var str = Encoding.Unicode.GetString(data);
                File.WriteAllBytes("a.pdf",data);
                Process.Start("a.pdf");

            }
            public void TestConstructorItemWithPerson()
            {
                var t = new Person {Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/"};
                var export = new ExportExcel2003<Person>();
                Assert.AreEqual(@"<Row>
   <Cell><Data ss:Type='String'>@Model.Name</Data></Cell>
   <Cell><Data ss:Type='String'>@Model.WebSite</Data></Cell>
   <Cell><Data ss:Type='String'>@Model.CV</Data></Cell>
</Row>", export.ExportItem);
            }
            public void TestConstructorHeaderWithPerson()
            {
                var t = new Person {Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/"};
                var export = new ExportExcel2003<Person>();
                Assert.AreEqual(@"<Row>
   <Cell ss:StyleID='s21'><Data ss:Type='String'>Name</Data></Cell>
   <Cell ss:StyleID='s21'><Data ss:Type='String'>WebSite</Data></Cell>
   <Cell ss:StyleID='s21'><Data ss:Type='String'>CV</Data></Cell>
</Row>", export.ExportHeader);
            }
            //[TestMethod]
            public void TestExcel()
            {
                var p = new Person { Name = "Andrei Ignat", WebSite = "http://msprogrammer.serviciipeweb.ro/", CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" };
                var export = new ExportExcel2003<Person>();
                var data = export.ExportResult(new List<Person>() { p });
                var str = Encoding.Unicode.GetString(data);
                File.WriteAllText("a.xls",str);
                Process.Start("a.xls");

            }
            public void TestConstructorItemWithPerson()
            {
                var t = new Person {Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/"};
                var export = new ExportPdfiTextSharp4<Person>();
                Assert.AreEqual(@"<row>
    <cell><phrase font='Times New Roman' size='8'>@Model.Name</phrase></cell>
    <cell><phrase font='Times New Roman' size='8'>@Model.WebSite</phrase></cell>
    <cell><phrase font='Times New Roman' size='8'>@Model.CV</phrase></cell>
</row>", export.ExportItem);
            }
            public void TestConstructorHeaderWithPerson()
            {
                var t = new Person {Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/"};
                var export = new ExportPdfiTextSharp4<Person>();
                Assert.AreEqual(@"<row>
<cell><phrase font='Arial' size='12' style='bold'>Name</phrase></cell>
<cell><phrase font='Arial' size='12' style='bold'>WebSite</phrase></cell>
<cell><phrase font='Arial' size='12' style='bold'>CV</phrase></cell>
</row>", export.ExportHeader);
            }
Esempio n. 14
0
            public void TestCorrectCSV()
            {
                var data = new List<string>();
                data.Add("Name,WebSite,CV");
                data.Add("Andrei Ignat,http://msprogrammer.serviciipeweb.ro/,http://serviciipeweb.ro/iafblog/content/binary/cv.doc");
                data.Add("Andrei Ignat,http://msprogrammer.serviciipeweb.ro/,http://serviciipeweb.ro/iafblog/content/binary/cv.doc");

                var p = new Person { Name = "Andrei Ignat", WebSite = "http://msprogrammer.serviciipeweb.ro/", CV = "http://serviciipeweb.ro/iafblog/content/binary/cv.doc" };

                var byte1 = new ExportExcel2007<Person>().ExportResult(new List<Person>() { p, p });

                var byte2 = ExportFactory.ExportDataCsv(data.ToArray(), ExportToFormat.Excel2007);

                Assert.IsTrue(Math.Abs(byte1.Length - byte2.Length) < 100);


            }
            public void TestConstructorHeaderWithPerson()
            {
                var t = new Person {Name = "andrei", WebSite = "http://msprogrammer.serviciipeweb.ro/"};
                var export = new ExportWord2003<Person>();
                Assert.AreEqual(@"<w:tr>
           <w:tc>
                <w:p>
                    <w:r>
                        <w:rPr>
                            <w:b w:val='on'/>
                            <w:t>
                                Name
                            </w:t>
                        </w:rPr>
                    </w:r>
                </w:p>
            </w:tc>                
           <w:tc>
                <w:p>
                    <w:r>
                        <w:rPr>
                            <w:b w:val='on'/>
                            <w:t>
                                WebSite
                            </w:t>
                        </w:rPr>
                    </w:r>
                </w:p>
            </w:tc>                
           <w:tc>
                <w:p>
                    <w:r>
                        <w:rPr>
                            <w:b w:val='on'/>
                            <w:t>
                                CV
                            </w:t>
                        </w:rPr>
                    </w:r>
                </w:p>
            </w:tc>                
</w:tr>", export.ExportHeader);
            }