public void GetCellContents03() { SpreadsheetTests01 s1 = new SpreadsheetTests01(); s1.SetCellContents("z1", 0.8); s1.GetCellContents(null); }
public void GetNamesOfAllNonemptyCells01() { SpreadsheetTests01 s1 = new SpreadsheetTests01(); List <string> nonEmptyCells = new List <string>(s1.GetNamesOfAllNonemptyCells()); Assert.AreEqual(0, nonEmptyCells.Count); }
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()); }
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")); }
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 }
public void SetCellContentsText06() { SpreadsheetTests01 s1 = new SpreadsheetTests01(); s1.SetCellContents("A1", ""); Assert.AreEqual(s1.GetCellContents("a1"), ""); }
public void SetContentsOfCell11() { SpreadsheetTests01 s1 = new SpreadsheetTests01(); s1.SetContentsOfCell("azf23", "hello"); Assert.AreEqual("hello", s1.GetCellValue("azF23")); }
public void GetCellContents01() { SpreadsheetTests01 s1 = new SpreadsheetTests01(); s1.SetCellContents("zz1", 0.8); Assert.AreEqual(s1.GetCellContents("zz1"), 0.8); }
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")); }
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")); }
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")); }
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"); }
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); }
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")); }
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")); }
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")); }
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")); }
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); }
public void XMLExceptions07() { SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText(@"../../ IllegalChars.xml")); }
public void XMLExceptions06() { SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText("")); }
public void XMLExceptions05() { SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText(@"../../ ValidationError.xml")); }
public void XMLExceptions04() { SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText(@"../../ Circular.xml")); }
public void XMLExceptions03() { SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText(@"../../ InValidForula.xml")); }
public void XMLExceptions02() { SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText(@"../../ InValidCellName.xml")); }
public void XMLExceptions01() { SpreadsheetTests01 s2 = new SpreadsheetTests01(File.OpenText(@"../../ duplicateCells.xml")); }
public void SaveAndDuplicate02() { TextReader tr = null; SpreadsheetTests01 s2 = new SpreadsheetTests01(tr); }
public void Save01() { SpreadsheetTests01 s1 = new SpreadsheetTests01(new Regex("^[A-Z]*[1-2]$")); s1.Save(null); }
public void GetCellValue03() { SpreadsheetTests01 s1 = new SpreadsheetTests01(new Regex("^[A-Z]*[1-2]$")); s1.GetCellValue("A23"); }
public void GetCellValue02() { SpreadsheetTests01 s1 = new SpreadsheetTests01(); s1.GetCellValue("b1a1"); }
public void GetCellValue01() { SpreadsheetTests01 s1 = new SpreadsheetTests01(); s1.GetCellValue(null); }