Exemplo n.º 1
0
        public void GetCellContents03()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.SetCellContents("z1", 0.8);
            s1.GetCellContents(null);
        }
Exemplo n.º 2
0
        public void GetNamesOfAllNonemptyCells01()
        {
            SpreadsheetTests01 s1            = new SpreadsheetTests01();
            List <string>      nonEmptyCells = new List <string>(s1.GetNamesOfAllNonemptyCells());

            Assert.AreEqual(0, nonEmptyCells.Count);
        }
Exemplo n.º 3
0
        public void SetCellContentsFormula05()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.SetCellContents("a57", new Formula("b23 + a1 * g42"));
            Assert.AreEqual(s1.GetCellContents("A57").ToString(), new Formula("B23+A1*G42").ToString());
        }
Exemplo n.º 4
0
        public void SetContentsOfCell14()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01(new Regex("^[A-Z]*[1-2]$"));

            s1.SetContentsOfCell("A2", "2.0");
            Assert.AreEqual(2.0, s1.GetCellValue("A2"));
        }
Exemplo n.º 5
0
        public void SetContentsOfCell15()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            Assert.IsFalse(s1.Changed);

            s1.SetContentsOfCell("B2", "=A2 + c1");
            s1.SetContentsOfCell("c1", "=a2");
            s1.SetContentsOfCell("d1", "1.9");
            Assert.AreEqual(1.9, s1.GetCellValue("d1"));

            HashSet <string> dependents = new HashSet <string>(s1.SetContentsOfCell("A2", "2.0"));

            Assert.AreEqual(2.0, s1.GetCellValue("A2"));
            Assert.IsTrue(s1.Changed);

            Assert.IsTrue(dependents.Contains("A2"));
            Assert.IsTrue(dependents.Contains("B2"));
            Assert.IsTrue(dependents.Contains("C1"));
            Assert.IsFalse(dependents.Contains("D1"));

            // Were the dependent cells recalculated (and independent left untouched)?
            Assert.AreEqual(4.0, s1.GetCellValue("b2"));        // dependent
            Assert.AreEqual(2.0, s1.GetCellValue("c1"));        // dependent
            Assert.AreEqual(1.9, s1.GetCellValue("d1"));        // independent
        }
Exemplo n.º 6
0
        public void SetCellContentsText06()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.SetCellContents("A1", "");
            Assert.AreEqual(s1.GetCellContents("a1"), "");
        }
Exemplo n.º 7
0
        public void SetContentsOfCell11()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.SetContentsOfCell("azf23", "hello");
            Assert.AreEqual("hello", s1.GetCellValue("azF23"));
        }
Exemplo n.º 8
0
        public void GetCellContents01()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.SetCellContents("zz1", 0.8);

            Assert.AreEqual(s1.GetCellContents("zz1"), 0.8);
        }
Exemplo n.º 9
0
        public void SetCellContentsFormula07()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.SetCellContents("a1", new Formula("b1*2"));
            s1.SetCellContents("b1", new Formula("c1*2"));
            s1.SetCellContents("c1", new Formula("a1*2"));
        }
Exemplo n.º 10
0
        public void SetContentsOfCell09()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.SetContentsOfCell("a52", "=A1 + B1");

            FormulaError err = (FormulaError)s1.GetCellValue("A52");

            Assert.AreEqual(new FormulaError(err.Reason), s1.GetCellValue("A52"));
        }
Exemplo n.º 11
0
        public void SetContentsOfCell07()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01(new Regex("^[A-Z]*[1-2]$"));

            s1.SetContentsOfCell("A2", "=A1 + B1");

            FormulaError err = (FormulaError)s1.GetCellValue("A2");

            Assert.AreEqual(new FormulaError(err.Reason), s1.GetCellValue("A2"));
        }
Exemplo n.º 12
0
        public void SetCellContentsText05()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.SetCellContents("A1", "Pikachu");
            Assert.AreEqual(s1.GetCellContents("a1"), "Pikachu");

            s1.SetCellContents("A1", "Balbasaur");
            Assert.AreEqual(s1.GetCellContents("a1"), "Balbasaur");
        }
Exemplo n.º 13
0
        public void SetCellContentsDouble05()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.SetCellContents("a1", 0.8);
            Assert.AreEqual(s1.GetCellContents("a1"), 0.8);

            //Replace the contents
            s1.SetCellContents("a1", 1.8);
            Assert.AreEqual(s1.GetCellContents("a1"), 1.8);
        }
Exemplo n.º 14
0
        public void SetCellContentsDouble01()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.SetCellContents("b1", new Formula("a1*2"));
            s1.SetCellContents("c1", new Formula("b1+a1"));
            HashSet <string> dependents = new HashSet <string>(s1.SetCellContents("a1", 1.0));

            Assert.IsTrue(dependents.Contains("A1"));
            Assert.IsTrue(dependents.Contains("B1"));
            Assert.IsTrue(dependents.Contains("C1"));
        }
Exemplo n.º 15
0
        public void SetCellContentsFormula09()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.SetCellContents("b1", new Formula("c1*2"));
            s1.SetCellContents("c1", new Formula("a1*2"));
            s1.SetCellContents("d1", new Formula("2.2"));
            HashSet <string> dependents = new HashSet <string>(s1.SetCellContents("a1", new Formula("2.0")));

            Assert.IsTrue(dependents.Contains("B1"));
            Assert.IsTrue(dependents.Contains("C1"));
            Assert.IsFalse(dependents.Contains("D1"));
        }
Exemplo n.º 16
0
        public void GetNamesOfAllNonemptyCells02()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.SetCellContents("a1", "");
            s1.SetCellContents("b1", "Hi");
            s1.SetCellContents("c1", 2.0);

            List <string> nonEmptyCells = new List <string>(s1.GetNamesOfAllNonemptyCells());

            Assert.AreEqual(2, nonEmptyCells.Count);
            Assert.IsTrue(nonEmptyCells.Contains("B1"));
            Assert.IsTrue(nonEmptyCells.Contains("C1"));
            Assert.IsFalse(nonEmptyCells.Contains("A1"));
        }
Exemplo n.º 17
0
        public void SetCellContentsText07()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.SetCellContents("b1", new Formula("c1 * 2"));
            s1.SetCellContents("c1", new Formula("a1 * a1"));
            s1.SetCellContents("d1", new Formula("c1 * b1"));
            s1.SetCellContents("z1", "Hello");

            HashSet <string> dependents = new HashSet <string>(s1.SetCellContents("A1", "2"));

            Assert.IsTrue(dependents.Contains("B1"));
            Assert.IsTrue(dependents.Contains("C1"));
            Assert.IsTrue(dependents.Contains("D1"));
            Assert.IsFalse(dependents.Contains("Z1"));
        }
Exemplo n.º 18
0
        public void SaveAndDuplicate01()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01(new Regex("^[A-Z]*[1-2]$"));

            s1.SetContentsOfCell("A1", "2.0");
            s1.SetContentsOfCell("B1", "Garfield");
            s1.SetContentsOfCell("C1", "=A1 * 2");
            s1.SetContentsOfCell("D1", "");

            s1.Save(File.CreateText("../../ spreadsheetTest01.xml"));

            SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText(@"../../ spreadsheetTest01.xml"));

            Assert.AreEqual(2.0, s2.GetCellContents("A1"));
            Assert.AreEqual("Garfield", s2.GetCellContents("B1"));
            Assert.AreEqual(new Formula("A1 * 2").ToString(), s2.GetCellContents("C1").ToString());
            Assert.IsFalse(s2.Changed);
        }
Exemplo n.º 19
0
 public void XMLExceptions07()
 {
     SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText(@"../../ IllegalChars.xml"));
 }
Exemplo n.º 20
0
 public void XMLExceptions06()
 {
     SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText(""));
 }
Exemplo n.º 21
0
 public void XMLExceptions05()
 {
     SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText(@"../../ ValidationError.xml"));
 }
Exemplo n.º 22
0
 public void XMLExceptions04()
 {
     SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText(@"../../ Circular.xml"));
 }
Exemplo n.º 23
0
 public void XMLExceptions03()
 {
     SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText(@"../../ InValidForula.xml"));
 }
Exemplo n.º 24
0
 public void XMLExceptions02()
 {
     SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText(@"../../ InValidCellName.xml"));
 }
Exemplo n.º 25
0
 public void XMLExceptions01()
 {
     SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText(@"../../ duplicateCells.xml"));
 }
Exemplo n.º 26
0
 public void SaveAndDuplicate02()
 {
     TextReader         tr = null;
     SpreadsheetTests01 s2 = new SpreadsheetTests01(tr);
 }
Exemplo n.º 27
0
        public void Save01()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01(new Regex("^[A-Z]*[1-2]$"));

            s1.Save(null);
        }
Exemplo n.º 28
0
        public void GetCellValue03()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01(new Regex("^[A-Z]*[1-2]$"));

            s1.GetCellValue("A23");
        }
Exemplo n.º 29
0
        public void GetCellValue02()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.GetCellValue("b1a1");
        }
Exemplo n.º 30
0
        public void GetCellValue01()
        {
            SpreadsheetTests01 s1 = new SpreadsheetTests01();

            s1.GetCellValue(null);
        }