Example #1
0
        public void ExcelTypeConfigurationTest()
        {
            ExcelTypeConfiguration c0 = new ExcelTypeConfiguration();
            ExcelTypeConfiguration c1 = new ExcelTypeConfiguration(HeaderCollection.Create(new Header("h1", 1)));
            ExcelTypeConfiguration c2 = new ExcelTypeConfiguration("dd/MM/yyyy");
            ExcelTypeConfiguration c3 = new ExcelTypeConfiguration(HeaderCollection.Create(new Header("h1", 1)), "dd/MM/yyyy");

            Assert.AreEqual(c0.DateFormat, "yyyy-MM-dd");
            Assert.AreEqual(c1.DateFormat, "yyyy-MM-dd");
            Assert.AreEqual(c2.DateFormat, "dd/MM/yyyy");
            Assert.AreEqual(c3.DateFormat, "dd/MM/yyyy");

            Assert.AreEqual(c0.DecimalFormat, "#,##0.00");
            Assert.AreEqual(c1.DecimalFormat, "#,##0.00");
            Assert.AreEqual(c2.DecimalFormat, "#,##0.00");
            Assert.AreEqual(c3.DecimalFormat, "#,##0.00");

            Assert.IsNull(c0.Headers);
            Assert.IsNotNull(c1.Headers);
            Assert.IsNull(c2.Headers);
            Assert.IsNotNull(c3.Headers);

            Assert.IsTrue(c1.Headers.Count == 1);
            Assert.IsTrue(c3.Headers.Count == 1);
        }
        public void HeaderCollectionFabricTest()
        {
            HeaderCollection headers1 = HeaderCollection.Create(new Header("t1", 2));
            HeaderCollection headers2 = HeaderCollection.Create(
                new Header[] {
                new Header("t2", 3),
                new Header("t3", 4)
            });

            HeaderCollection headers3 = HeaderCollection.Create(new List <Header>(2)
            {
                new Header("t2", 3),
                new Header("t3", 4)
            });

            HeaderCollection headers4 = HeaderCollection.Create(10, "p");
            HeaderCollection headers5 = HeaderCollection.Create(10);

            Assert.AreEqual(headers1.Count, 1);
            Assert.AreEqual(headers1[0].Title, "t1");
            Assert.AreEqual(headers1[0].Order, 2);

            Assert.AreEqual(headers2.Count, 2);
            Assert.AreEqual(headers2[0].Title, "t2");
            Assert.AreEqual(headers2[0].Order, 3);
            Assert.AreEqual(headers2[1].Title, "t3");
            Assert.AreEqual(headers2[1].Order, 4);

            Assert.AreEqual(headers3.Count, 2);
            Assert.AreEqual(headers3[0].Title, "t2");
            Assert.AreEqual(headers3[0].Order, 3);
            Assert.AreEqual(headers3[1].Title, "t3");
            Assert.AreEqual(headers3[1].Order, 4);

            Assert.AreEqual(headers4.Count, 10);
            Assert.AreEqual(headers5.Count, 10);
        }