Esempio n. 1
0
        public void TestConstructor()
        {
            //just some stuff with filewriting
            Assert.IsTrue(sheet1.IsValid("any old string"));
            Assert.IsTrue(sheet1.Normalize("dead") == "dead");
            Assert.IsTrue(sheet1.Version == "default");

            //test 3 arg constructor
            sheet1 = new Spreadsheet(s => (s.Length >= 2) ? true : false,
                s => s.Replace(" ", ""),
                "version1");
            Assert.IsTrue(sheet1.IsValid("A1"));
            Assert.IsFalse(sheet1.IsValid("A"));
            Assert.IsTrue(sheet1.Normalize("d e a d") == "dead");
            Assert.IsTrue(sheet1.Version == "version1");
            sheet1.SetContentsOfCell("A     1","loaded!");

            string savePath = "save 1.xml";
            sheet1.Save(savePath);
            sheet1 = new Spreadsheet(
                savePath,
                s => (s.Length >= 2) ? true : false,
                s => s.Replace(" ", ""),
                "version1");
            Assert.AreEqual("loaded!",(string)sheet1.GetCellContents("A1"));
        }
 public void SpreadsheetFourArgumentConstructorTest()
 {
     if (!File.Exists("fourarg.xml"))
     {
         Spreadsheet old = new Spreadsheet(TestValidToTrue, TestNormalizeToUpperCase, "2.2");
         old.SetContentsOfCell("A1", "asdf");
         old.SetContentsOfCell("B2", "23");
         old.Save("fourarg.xml");
     }
     Spreadsheet s = new Spreadsheet("fourarg.xml", TestValidToTrue, TestNormalizeToUpperCase, "2.2");
     Assert.AreEqual(true, s.IsValid("a"));
     Assert.AreEqual("A", s.Normalize("a"));
     Assert.AreEqual("asdf", s.GetCellContents("A1"));
     Assert.AreEqual(23.0, s.GetCellContents("B2"));
     Assert.AreEqual(23.0, s.GetCellValue("B2"));
     Assert.AreEqual("2.2", s.Version);
 }
 public void SpreadsheetThreeArgumentConstructorTest()
 {
     Spreadsheet s = new Spreadsheet(TestValidToFalse, TestNormalizeToUpperCase, "1.1");
     Assert.AreEqual(false, s.IsValid("a"));
     Assert.AreEqual("A1", s.Normalize("a1"));
     Assert.AreEqual("1.1", s.Version);
 }
 public void SpreadsheetTest()
 {
     Spreadsheet s = new Spreadsheet();
     Assert.AreEqual("a", s.Normalize("a"));
     Assert.AreEqual(true, s.IsValid("a"));
     Assert.AreEqual("default", s.Version);
 }