Esempio n. 1
0
        public void TestMethod13()
        {
            var spreadsheet = new SS.Spreadsheet();
            var resolve     = _variableResolver(spreadsheet);
            var random      = new Random();

            for (var x = 'A'; x <= 'Z'; x++)
            {
                double sum        = 0;
                var    expression = "";

                const int count = 30;
                for (var y = 1; y < count; y++)
                {
                    var cell      = x.ToString() + y;
                    var randomNum = random.Next(1, 200);

                    spreadsheet.SetCellContents(cell, randomNum);
                    sum += randomNum;

                    // Adds the cell with a + //
                    expression += (y == count - 1) ? cell : cell + "+";
                }

                var cellName = x + count.ToString();

                spreadsheet.SetCellContents(cellName, new Formula(expression));

                var formula = spreadsheet.GetCellContents(cellName) as Formula;

                Assert.IsNotNull(formula);

                Assert.AreEqual(sum, formula.Evaluate(resolve));
            }
        }
Esempio n. 2
0
 public void TestCircularReference4()
 {
     AbstractSpreadsheet sheet = new Spreadsheet();
     sheet.SetCellContents("A1", 2.0);
     sheet.SetCellContents("A1", new Formula("A1*B1*2/4"));
     Assert.Fail();
 }
Esempio n. 3
0
        public void TestMethod5()
        {
            var spreadsheet = new SS.Spreadsheet();

            spreadsheet.SetCellContents("A1", new Formula("B1"));
            spreadsheet.SetCellContents("B1", new Formula("A1"));
        }
Esempio n. 4
0
        public void TestMethod4()
        {
            var spreadsheet = new SS.Spreadsheet();

            spreadsheet.SetCellContents("A1", "Title");
            spreadsheet.SetCellContents("A2", "Tesla #1");
            spreadsheet.SetCellContents("A3", "Tesla #2");
            spreadsheet.SetCellContents("A4", "Tesla #3");
            spreadsheet.SetCellContents("A5", "Total:");

            spreadsheet.SetCellContents("B1", "Sales");
            spreadsheet.SetCellContents("B2", 75000);
            spreadsheet.SetCellContents("B3", 85000);
            spreadsheet.SetCellContents("B4", 90000);
            spreadsheet.SetCellContents("B5", new Formula("B2+B3+B4"));

            var resolve = _variableResolver(spreadsheet);

            var a1 = spreadsheet.GetCellContents("A1") as string;
            var b2 = spreadsheet.GetCellContents("B2") as double?;
            var b5 = spreadsheet.GetCellContents("B5") as Formula;

            Assert.IsNotNull(a1);
            Assert.IsNotNull(b2);
            Assert.IsNotNull(b5);

            Assert.AreEqual("Title", a1);
            Assert.AreEqual(75000, b2);
            Assert.AreEqual(75000 + 85000 + 90000d, b5.Evaluate(resolve));
        }
        public void GetNamesOfAllNonemptyCellsTest4()
        {
            Spreadsheet test_spreadsheet = new Spreadsheet();
            test_spreadsheet.SetCellContents("A1", "x+1");
            test_spreadsheet.SetCellContents("A1", "");

            Assert.AreEqual(0, new List<string>(test_spreadsheet.GetNamesOfAllNonemptyCells()).Count);
        }
Esempio n. 6
0
 public void SetStringContentTwice()
 {
     Spreadsheet sheet = new Spreadsheet();
     sheet.SetCellContents("A1", "blue");
     sheet.SetCellContents("A1", "green");
     Assert.AreEqual(sheet.GetCellContents("A1"), "green");
     Assert.AreNotEqual(sheet.GetCellContents("A1"), "blue");
 }
Esempio n. 7
0
        public void Test26()
        {
            Spreadsheet s = new Spreadsheet();

            s.SetCellContents("A1", 17.2);
            s.SetCellContents("B1", "hello");
            Assert.IsTrue(s.SetCellContents("C1", new Formula("5")).SetEquals(new HashSet <string>()
            {
                "C1"
            }));
        }
Esempio n. 8
0
        public void GetCellContentsFormula()
        {
            Spreadsheet sheet = new Spreadsheet();
            sheet.SetCellContents("A1", "blue");
            sheet.SetCellContents("A1", "green");
            sheet.SetCellContents("B1", "purple");
            sheet.SetCellContents("C1", "red");
            sheet.SetCellContents("D1", new Formula("C1 + 2 + X1"));

            Assert.AreEqual(sheet.GetCellContents("D1"), new Formula("C1+2+X1"));
        }
Esempio n. 9
0
        public void Test23()
        {
            Spreadsheet s = new Spreadsheet();

            s.SetCellContents("A1", 17.2);
            s.SetCellContents("C1", "hello");
            s.SetCellContents("B1", new Formula("3.5"));
            Assert.IsTrue(new HashSet <string>(s.GetNamesOfAllNonemptyCells()).SetEquals(new HashSet <string>()
            {
                "A1", "B1", "C1"
            }));
        }
Esempio n. 10
0
        public void TestMethod18()
        {
            var spreadsheet = new SS.Spreadsheet();

            spreadsheet.SetCellContents("A1", 2.0);
            spreadsheet.SetCellContents("B1", 45.0);
            spreadsheet.SetCellContents("C1", new Formula("A1 + B1"));

            var result = spreadsheet.SetCellContents("C1", 3.0);

            Assert.IsTrue(!result.Contains("B1") && !result.Contains("A1"));
        }
Esempio n. 11
0
        public void TestMethod17()
        {
            var spreadsheet = new SS.Spreadsheet();

            spreadsheet.SetCellContents("A1", 2.0);
            spreadsheet.SetCellContents("B1", 45.0);
            spreadsheet.SetCellContents("C1", new Formula("A1 + B1"));

            var result = spreadsheet.SetCellContents("A1", 3.0); // Should update them other cells //

            Assert.IsTrue(result.Contains("A1") && result.Contains("C1"));
        }
Esempio n. 12
0
        public void Test16()
        {
            Formula     circular = new Formula("A1+A1");
            Formula     A1       = new Formula("A2+A3");
            Formula     A3       = new Formula("A4+A5");
            Formula     A5       = new Formula("A6+A7");
            Spreadsheet s        = new Spreadsheet();

            s.SetCellContents("A1", A1);
            s.SetCellContents("A3", A3);
            s.SetCellContents("A5", A5);
            s.SetCellContents("A7", circular);
        }
Esempio n. 13
0
        public void Test27()
        {
            Spreadsheet s = new Spreadsheet();

            s.SetCellContents("A1", new Formula("A2+A3"));
            s.SetCellContents("A2", 6);
            s.SetCellContents("A3", new Formula("A2+A4"));
            s.SetCellContents("A4", new Formula("A2+A5"));
            Assert.IsTrue(s.SetCellContents("A5", 82.5).SetEquals(new HashSet <string>()
            {
                "A5", "A4", "A3", "A1"
            }));
        }
Esempio n. 14
0
        public void TestMethod3()
        {
            var spreadsheet = new SS.Spreadsheet();

            spreadsheet.SetCellContents("A1", 1);
            spreadsheet.SetCellContents("A2", 2);
            spreadsheet.SetCellContents("A3", new Formula("A1 + A2"));
            spreadsheet.SetCellContents("B1", 3);
            spreadsheet.SetCellContents("B2", 4);
            spreadsheet.SetCellContents("B3", new Formula("B1 + B2"));
            spreadsheet.SetCellContents("C3", new Formula("A3 + B3"));
            spreadsheet.SetCellContents("D3", new Formula("C3 / 2"));

            var resolve = _variableResolver(spreadsheet);

            var a3 = spreadsheet.GetCellContents("A3") as Formula;
            var b3 = spreadsheet.GetCellContents("B3") as Formula;
            var c3 = spreadsheet.GetCellContents("C3") as Formula;
            var d3 = spreadsheet.GetCellContents("D3") as Formula;

            Assert.IsNotNull(a3);
            Assert.IsNotNull(b3);
            Assert.IsNotNull(c3);
            Assert.IsNotNull(d3);

            Assert.AreEqual(3d, a3.Evaluate(resolve));
            Assert.AreEqual(7d, b3.Evaluate(resolve));
            Assert.AreEqual(10d, c3.Evaluate(resolve));
            Assert.AreEqual(5d, d3.Evaluate(resolve));
        }
Esempio n. 15
0
        public void Test19()
        {
            Spreadsheet s = new Spreadsheet();

            s.SetCellContents("B1", "");
            Assert.IsFalse(s.GetNamesOfAllNonemptyCells().GetEnumerator().MoveNext());
        }
Esempio n. 16
0
        public void TestMethod15()
        {
            var spreadsheet = new SS.Spreadsheet();

            spreadsheet.SetCellContents("A1", 2.0);
            spreadsheet.SetCellContents("C1", new Formula("A1"));

            var resolve = _variableResolver(spreadsheet);

            var formula = spreadsheet.GetCellContents("C1") as Formula;

            Assert.IsNotNull(formula);
            Assert.AreEqual(formula, new Formula("A1"));

            Assert.AreEqual(2d, formula.Evaluate(resolve));
        }
Esempio n. 17
0
        public void Test6()
        {
            Spreadsheet s = new Spreadsheet();

            s.SetCellContents("Z7", 1.5);
            Assert.AreEqual(1.5, (double)s.GetCellContents("Z7"), 1e-9);
        }
Esempio n. 18
0
        public void TestMethod16()
        {
            var spreadsheet = new SS.Spreadsheet();

            var random = new Random();

            var listOfNonEmpty = new List <string>();

            foreach (var cell in GenerateCells(26, 26))
            {
                var shouldBeEmpty = random.Next() % 2 == 0;

                spreadsheet.SetCellContents(cell, shouldBeEmpty ? string.Empty : "Not empty bro");

                if (!shouldBeEmpty)
                {
                    listOfNonEmpty.Add(cell);
                }
            }

            var notEmpties = spreadsheet.GetNamesOfAllNonemptyCells().ToList();

            foreach (var element in notEmpties)
            {
                Assert.IsTrue(listOfNonEmpty.Contains(element));
            }
        }
 public void GetNamesOfAllNonemptyCellsTest2()
 {
     Spreadsheet test_spreadsheet = new Spreadsheet();
     test_spreadsheet.SetCellContents("A1", new Formula("x+1"));
     Assert.AreEqual("A1", new List<string>(test_spreadsheet.GetNamesOfAllNonemptyCells())[0]);
     Assert.AreEqual(1, new List<string>(test_spreadsheet.GetNamesOfAllNonemptyCells()).Count);
 }
Esempio n. 20
0
        public void Test10()
        {
            Spreadsheet s = new Spreadsheet();

            s.SetCellContents("Z7", "hello");
            Assert.AreEqual("hello", s.GetCellContents("Z7"));
        }
Esempio n. 21
0
        public void TestMethod7()
        {
            var spreadsheet = new SS.Spreadsheet();

            spreadsheet.SetCellContents("_kanye_west", 2.0);
            spreadsheet.SetCellContents("_kanye_north", 45.0);
            spreadsheet.SetCellContents("C1", new Formula("_kanye_west + _kanye_north"));

            var resolve = _variableResolver(spreadsheet);

            var formula = spreadsheet.GetCellContents("C1") as Formula;

            Assert.IsNotNull(formula);
            Assert.AreEqual(formula, new Formula("_kanye_west + _kanye_north"));

            Assert.AreEqual(47.0d, formula.Evaluate(resolve));
        }
Esempio n. 22
0
        public void Test39()
        {
            Spreadsheet s = new Spreadsheet();

            for (int i = 1; i < 200; i++)
            {
                s.SetCellContents("A" + i, new Formula("A" + (i + 1)));
            }
            try
            {
                s.SetCellContents("A150", new Formula("A50"));
                Assert.Fail();
            }
            catch (CircularException)
            {
            }
        }
Esempio n. 23
0
        public void Test17()
        {
            Spreadsheet s = new Spreadsheet();

            try
            {
                s.SetCellContents("A1", new Formula("A2+A3"));
                s.SetCellContents("A2", 15);
                s.SetCellContents("A3", 30);
                s.SetCellContents("A2", new Formula("A3*A1"));
            }
            catch (CircularException e)
            {
                Assert.AreEqual(15, (double)s.GetCellContents("A2"), 1e-9);
                throw e;
            }
        }
Esempio n. 24
0
        public void TestMethod2()
        {
            var spreadsheet = new SS.Spreadsheet();

            spreadsheet.SetCellContents("A1", 2.0);
            spreadsheet.SetCellContents("B1", 45.0);
            spreadsheet.SetCellContents("C1", new Formula("A1 + B1"));
            spreadsheet.SetCellContents("D1", new Formula("C1 + A1"));

            var resolve = _variableResolver(spreadsheet);

            var d1 = spreadsheet.GetCellContents("D1") as Formula;

            Assert.IsNotNull(d1);
            Assert.AreEqual(d1, new Formula("C1 + A1"));

            Assert.AreEqual(49.0d, d1.Evaluate(resolve));
        }
Esempio n. 25
0
        public void Test43()
        {
            Spreadsheet s = new Spreadsheet();

            for (int i = 0; i < 500; i++)
            {
                s.SetCellContents("A1" + i, new Formula("A1" + (i + 1)));
            }
            HashSet <string> firstCells = new HashSet <string>();
            HashSet <string> lastCells  = new HashSet <string>();

            for (int i = 0; i < 250; i++)
            {
                firstCells.Add("A1" + i);
                lastCells.Add("A1" + (i + 250));
            }
            Assert.IsTrue(s.SetCellContents("A1249", 25.0).SetEquals(firstCells));
            Assert.IsTrue(s.SetCellContents("A1499", 0).SetEquals(lastCells));
        }
Esempio n. 26
0
        public void Test14()
        {
            Spreadsheet s = new Spreadsheet();

            s.SetCellContents("Z7", new Formula("3"));
            Formula f = (Formula)s.GetCellContents("Z7");

            Assert.AreEqual(new Formula("3"), f);
            Assert.AreNotEqual(new Formula("2"), f);
        }
Esempio n. 27
0
        public void Test21()
        {
            Spreadsheet s = new Spreadsheet();

            s.SetCellContents("B1", 52.25);
            Assert.IsTrue(new HashSet <string>(s.GetNamesOfAllNonemptyCells()).SetEquals(new HashSet <string>()
            {
                "B1"
            }));
        }
Esempio n. 28
0
        public void Test35()
        {
            Spreadsheet   s     = new Spreadsheet();
            ISet <String> cells = new HashSet <string>();

            for (int i = 1; i < 500; i++)
            {
                cells.Add("A" + i);
                Assert.IsTrue(cells.SetEquals(s.SetCellContents("A" + i, new Formula("A" + (i + 1)))));
            }
        }
Esempio n. 29
0
        public void Test27()
        {
            HashSet <string> fullSet = new HashSet <string>();

            Spreadsheet s = new Spreadsheet();

            s.SetCellContents("A1", new Formula("A2+A3"));
            s.SetCellContents("A2", 6);
            s.SetCellContents("A3", new Formula("A2+A4"));

            IEnumerator <string> str = s.SetCellContents("A4", new Formula("A2+A5")).GetEnumerator();

            while (str.MoveNext())
            {
                fullSet.Add(str.Current);
            }
            Assert.IsTrue(s.SetCellContents("A5", 82.5).SetEquals(new HashSet <string>()
            {
                "A5", "A4", "A3", "A1"
            }));
        }
Esempio n. 30
0
        public void TestGetNamesOfNonEmptyCells()
        {
            Spreadsheet sheet = new Spreadsheet();
            sheet.SetCellContents("A1", 10.5);
            sheet.SetCellContents("B1", "horse");
            sheet.SetCellContents("E1", 1.5);
            sheet.SetCellContents("A", "dad");

            var nameEnum = sheet.GetNamesOfAllNonemptyCells().GetEnumerator();

            List<object> names = new List<object>();
            for (int i = 0; i < 4; i++)
            {
                nameEnum.MoveNext();
                names.Add(nameEnum.Current);
            }
            
            Assert.IsTrue(names.Count == 4);

            Assert.IsTrue(names.Contains("A1"));
            Assert.IsTrue(names.Contains("B1"));
            Assert.IsTrue(names.Contains("E1"));
            Assert.IsTrue(names.Contains("A"));
        }
Esempio n. 31
0
        public void Test8()
        {
            Spreadsheet s = new Spreadsheet();

            s.SetCellContents(null, "hello");
        }
Esempio n. 32
0
 public void Test39()
 {
     Spreadsheet s = new Spreadsheet();
     for (int i = 1; i < 200; i++)
     {
         s.SetCellContents("A" + i, new Formula("A" + (i + 1)));
     }
     try
     {
         s.SetCellContents("A150", new Formula("A50"));
         Assert.Fail();
     }
     catch (CircularException)
     {
     }
 }
Esempio n. 33
0
 public void RunRandomizedTest (int seed, int size) 
 {
     Spreadsheet s = new Spreadsheet();
     Random rand = new Random(seed);
     for (int i = 0; i < 10000; i++)
     {
         try
         {
             switch (rand.Next(3))
             {
                 case 0:
                     s.SetCellContents(randomName(rand), 3.14);
                     break;
                 case 1:
                     s.SetCellContents(randomName(rand), "hello");
                     break;
                 case 2:
                     s.SetCellContents(randomName(rand), randomFormula(rand));
                     break;
             }
         }
         catch (CircularException)
         {
         }
     }
     ISet<string> set = new HashSet<string>(s.GetNamesOfAllNonemptyCells());
     Assert.AreEqual(size, set.Count);
 }
Esempio n. 34
0
 public void Test29()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("A1", new Formula("A2+A3"));
     s.SetCellContents("A1", "Hello");
     Assert.AreEqual("Hello", (string)s.GetCellContents("A1"));
 }
Esempio n. 35
0
 public void Test31()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("A1", new Formula("B1+B2"));
     s.SetCellContents("B1", new Formula("C1-C2"));
     s.SetCellContents("B2", new Formula("C3*C4"));
     s.SetCellContents("C1", new Formula("D1*D2"));
     s.SetCellContents("C2", new Formula("D3*D4"));
     s.SetCellContents("C3", new Formula("D5*D6"));
     s.SetCellContents("C4", new Formula("D7*D8"));
     s.SetCellContents("D1", new Formula("E1"));
     s.SetCellContents("D2", new Formula("E1"));
     s.SetCellContents("D3", new Formula("E1"));
     s.SetCellContents("D4", new Formula("E1"));
     s.SetCellContents("D5", new Formula("E1"));
     s.SetCellContents("D6", new Formula("E1"));
     s.SetCellContents("D7", new Formula("E1"));
     s.SetCellContents("D8", new Formula("E1"));
     ISet<String> cells = s.SetCellContents("E1", 0);
     Assert.IsTrue(new HashSet<string>(){"A1", "B1", "B2", "C1", "C2", "C3", "C4", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "E1"}.SetEquals(cells));
 }
Esempio n. 36
0
 public void Test23()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("A1", 17.2);
     s.SetCellContents("C1", "hello");
     s.SetCellContents("B1", new Formula("3.5"));
     Assert.IsTrue(new HashSet<string>(s.GetNamesOfAllNonemptyCells()).SetEquals(new HashSet<string>() { "A1", "B1", "C1" }));
 }
Esempio n. 37
0
 public void Test27()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("A1", new Formula("A2+A3"));
     s.SetCellContents("A2", 6);
     s.SetCellContents("A3", new Formula("A2+A4"));
     s.SetCellContents("A4", new Formula("A2+A5"));
     Assert.IsTrue(s.SetCellContents("A5", 82.5).SetEquals(new HashSet<string>() { "A5", "A4", "A3", "A1" }));
 }
Esempio n. 38
0
 public void Test9()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("1AZ", "hello");
 }
Esempio n. 39
0
 public void Test10()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("Z7", "hello");
     Assert.AreEqual("hello", s.GetCellContents("Z7"));
 }
Esempio n. 40
0
        public void Test31()
        {
            Spreadsheet s = new Spreadsheet();

            s.SetCellContents("A1", new Formula("B1+B2"));
            s.SetCellContents("B1", new Formula("C1-C2"));
            s.SetCellContents("B2", new Formula("C3*C4"));
            s.SetCellContents("C1", new Formula("D1*D2"));
            s.SetCellContents("C2", new Formula("D3*D4"));
            s.SetCellContents("C3", new Formula("D5*D6"));
            s.SetCellContents("C4", new Formula("D7*D8"));
            s.SetCellContents("D1", new Formula("E1"));
            s.SetCellContents("D2", new Formula("E1"));
            s.SetCellContents("D3", new Formula("E1"));
            s.SetCellContents("D4", new Formula("E1"));
            s.SetCellContents("D5", new Formula("E1"));
            s.SetCellContents("D6", new Formula("E1"));
            s.SetCellContents("D7", new Formula("E1"));
            s.SetCellContents("D8", new Formula("E1"));
            ISet <String> cells = s.SetCellContents("E1", 0);

            Assert.IsTrue(new HashSet <string>()
            {
                "A1", "B1", "B2", "C1", "C2", "C3", "C4", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "E1"
            }.SetEquals(cells));
        }
Esempio n. 41
0
 public void Test8()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents(null, "hello");
 }
Esempio n. 42
0
        public void Test4()
        {
            Spreadsheet s = new Spreadsheet();

            s.SetCellContents(null, 1.5);
        }
Esempio n. 43
0
        public void Test5()
        {
            Spreadsheet s = new Spreadsheet();

            s.SetCellContents("1A1A", 1.5);
        }
Esempio n. 44
0
        public void Test7()
        {
            Spreadsheet s = new Spreadsheet();

            s.SetCellContents("A8", (string)null);
        }
Esempio n. 45
0
 public void Test19()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("B1", "");
     Assert.IsFalse(s.GetNamesOfAllNonemptyCells().GetEnumerator().MoveNext());
 }
Esempio n. 46
0
 public void Test11()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("A8", (Formula)null);
 }
Esempio n. 47
0
 public void Test21()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("B1", 52.25);
     Assert.IsTrue(new HashSet<string>(s.GetNamesOfAllNonemptyCells()).SetEquals(new HashSet<string>() { "B1" }));
 }
Esempio n. 48
0
 public void Test12()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents(null, new Formula("2"));
 }
Esempio n. 49
0
 public void Test26()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("A1", 17.2);
     s.SetCellContents("B1", "hello");
     Assert.IsTrue(s.SetCellContents("C1", new Formula("5")).SetEquals(new HashSet<string>() { "C1" }));
 }
Esempio n. 50
0
 public void Test13()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("1AZ", new Formula("2"));
 }
Esempio n. 51
0
 public void Test28()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("A1", new Formula("A2+A3"));
     s.SetCellContents("A1", 2.5);
     Assert.AreEqual(2.5, (double)s.GetCellContents("A1"), 1e-9);
 }
Esempio n. 52
0
 public void Test14()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("Z7", new Formula("3"));
     Formula f = (Formula)s.GetCellContents("Z7");
     Assert.AreEqual(new Formula("3"), f);
     Assert.AreNotEqual(new Formula("2"), f);
 }
Esempio n. 53
0
 public void Test30()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("A1", "Hello");
     s.SetCellContents("A1", new Formula("23"));
     Assert.AreEqual(new Formula("23"), (Formula)s.GetCellContents("A1"));
     Assert.AreNotEqual(new Formula("24"), (Formula)s.GetCellContents("A1"));
 }
Esempio n. 54
0
 public void Test15()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("A1", new Formula("A2"));
     s.SetCellContents("A2", new Formula("A1"));
 }
Esempio n. 55
0
 public void Test35()
 {
     Spreadsheet s = new Spreadsheet();
     ISet<String> cells = new HashSet<string>();
     for (int i = 1; i < 200; i++)
     {
         cells.Add("A" + i);
         Assert.IsTrue(cells.SetEquals(s.SetCellContents("A" + i, new Formula("A" + (i + 1)))));
     }
 }
Esempio n. 56
0
 public void Test16()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents("A1", new Formula("A2+A3"));
     s.SetCellContents("A3", new Formula("A4+A5"));
     s.SetCellContents("A5", new Formula("A6+A7"));
     s.SetCellContents("A7", new Formula("A1+A1"));
 }
Esempio n. 57
0
 public void Test43()
 {
     Spreadsheet s = new Spreadsheet();
     for (int i = 0; i < 500; i++)
     {
         s.SetCellContents("A1" + i, new Formula("A1" + (i + 1)));
     }
     HashSet<string> firstCells = new HashSet<string>();
     HashSet<string> lastCells = new HashSet<string>();
     for (int i = 0; i < 250; i++)
     {
         firstCells.Add("A1" + i);
         lastCells.Add("A1" + (i + 250));
     }
     Assert.IsTrue(s.SetCellContents("A1249", 25.0).SetEquals(firstCells));
     Assert.IsTrue(s.SetCellContents("A1499", 0).SetEquals(lastCells));
 }
Esempio n. 58
0
 public void Test17()
 {
     Spreadsheet s = new Spreadsheet();
     try
     {
         s.SetCellContents("A1", new Formula("A2+A3"));
         s.SetCellContents("A2", 15);
         s.SetCellContents("A3", 30);
         s.SetCellContents("A2", new Formula("A3*A1"));
     }
     catch (CircularException e)
     {
         Assert.AreEqual(15, (double)s.GetCellContents("A2"), 1e-9);
         throw e;
     }
 }
Esempio n. 59
0
 public void Test4()
 {
     Spreadsheet s = new Spreadsheet();
     s.SetCellContents(null, 1.5); 
 }
Esempio n. 60
0
        public void Test9()
        {
            Spreadsheet s = new Spreadsheet();

            s.SetCellContents("1AZ", "hello");
        }