Пример #1
0
        public void Test22()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents("B1", new Formula("3.5"));
            AssertSetEqualsIgnoreCase(s.GetNamesOfAllNonemptyCells(), new string[] { "B1" });
        }
Пример #2
0
        public void Test14()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents("A1", new Formula("A2"));
            s.SetCellContents("A2", new Formula("A1"));
        }
Пример #3
0
        public void Test6()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents("Z7", 1.5);
            Assert.AreEqual(1.5, (double)s.GetCellContents("Z7"), 1e-9);
        }
Пример #4
0
        public void Test31()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            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);

            AssertSetEqualsIgnoreCase(new HashSet <string>()
            {
                "A1", "B1", "B2", "C1", "C2", "C3", "C4", "D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "E1"
            }, cells);
        }
Пример #5
0
        public void RunRandomizedTest(int seed, int size)
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();
            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);
        }
Пример #6
0
        public void Test10()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents("Z7", "hello");
            Assert.AreEqual("hello", s.GetCellContents("Z7"));
        }
Пример #7
0
        public void Test18()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents("B1", "");
            Assert.IsFalse(s.GetNamesOfAllNonemptyCells().GetEnumerator().MoveNext());
        }
Пример #8
0
        public void Test28()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents("A1", new Formula("A2+A3"));
            s.SetCellContents("A1", 2.5);
            Assert.AreEqual(2.5, (double)s.GetCellContents("A1"), 1e-9);
        }
Пример #9
0
        public void Test29()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents("A1", new Formula("A2+A3"));
            s.SetCellContents("A1", "Hello");
            Assert.AreEqual("Hello", (string)s.GetCellContents("A1"));
        }
Пример #10
0
        public void Test26()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents("A1", 17.2);
            s.SetCellContents("B1", "hello");
            AssertSetEqualsIgnoreCase(s.SetCellContents("C1", new Formula("5")), new string[] { "C1" });
        }
Пример #11
0
        public void Test30()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents("A1", "Hello");
            s.SetCellContents("A1", new Formula("23"));
            Assert.AreEqual(23, ((Formula)s.GetCellContents("A1")).Evaluate(x => 0));
        }
Пример #12
0
        public void Test13()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

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

            Assert.AreEqual(3, f.Evaluate(x => 0), 1e-6);
        }
Пример #13
0
        public void Test15()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            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"));
        }
Пример #14
0
        public void Test35()
        {
            TesttableSpreadsheet s     = new TesttableSpreadsheet();
            ISet <String>        cells = new HashSet <string>();

            for (int i = 1; i < 200; i++)
            {
                cells.Add("A" + i);
                AssertSetEqualsIgnoreCase(cells, s.SetCellContents("A" + i, new Formula("A" + (i + 1))));
            }
        }
Пример #15
0
        public void Test27()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            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"));
            HashSet <string> result = new HashSet <string>(s.SetCellContents("A5", 82.5));

            AssertSetEqualsIgnoreCase(result, new string[] { "A5", "A4", "A3", "A1" });
        }
Пример #16
0
        public void Test39()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            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)
            {
            }
        }
Пример #17
0
        public void Test16()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            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;
            }
        }
Пример #18
0
        public void Test43()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

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

            ISet <string> sss = s.SetCellContents("A1499", 25.0);

            Assert.AreEqual(500, sss.Count);
            for (int i = 0; i < 500; i++)
            {
                Assert.IsTrue(sss.Contains("A1" + i) || sss.Contains("a1" + i));
            }

            sss = s.SetCellContents("A1249", 25.0);
            Assert.AreEqual(250, sss.Count);
            for (int i = 0; i < 250; i++)
            {
                Assert.IsTrue(sss.Contains("A1" + i) || sss.Contains("a1" + i));
            }
        }
Пример #19
0
        public void Test3()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            Assert.AreEqual("", s.GetCellContents("A2"));
        }
Пример #20
0
        public void Test11()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents(null, new Formula("2"));
        }
Пример #21
0
        public void Test2()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.GetCellContents("AA");
        }
Пример #22
0
        public void Test1()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.GetCellContents(null);
        }
Пример #23
0
        public void Test9()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents("AZ", "hello");
        }
Пример #24
0
        public void Test4()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents(null, 1.5);
        }
Пример #25
0
        public void Test5()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents("A1A", 1.5);
        }
Пример #26
0
        public void Test17()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            Assert.IsFalse(s.GetNamesOfAllNonemptyCells().GetEnumerator().MoveNext());
        }
Пример #27
0
        public void Test7()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents("A8", (string)null);
        }
Пример #28
0
        public void Test8()
        {
            TesttableSpreadsheet s = new TesttableSpreadsheet();

            s.SetCellContents(null, "hello");
        }