Example #1
0
        public void Test10()
        {
            TestableSpreadsheet s = new TestableSpreadsheet();

            s.SetCellContents("Z7", "hello");
            Assert.AreEqual("hello", s.GetCellContents("Z7"));
        }
Example #2
0
        public void Test6()
        {
            TestableSpreadsheet s = new TestableSpreadsheet();

            s.SetCellContents("Z7", 1.5);
            Assert.AreEqual(1.5, (double)s.GetCellContents("Z7"), 1e-9);
        }
Example #3
0
        public void Test30()
        {
            TestableSpreadsheet s = new TestableSpreadsheet();

            s.SetCellContents("A1", "Hello");
            s.SetCellContents("A1", new Formula("23"));
            Assert.AreEqual(23, ((Formula)s.GetCellContents("A1")).Evaluate(x => 0));
        }
Example #4
0
        public void Test29()
        {
            TestableSpreadsheet s = new TestableSpreadsheet();

            s.SetCellContents("A1", new Formula("A2+A3"));
            s.SetCellContents("A1", "Hello");
            Assert.AreEqual("Hello", (string)s.GetCellContents("A1"));
        }
Example #5
0
        public void Test28()
        {
            TestableSpreadsheet s = new TestableSpreadsheet();

            s.SetCellContents("A1", new Formula("A2+A3"));
            s.SetCellContents("A1", 2.5);
            Assert.AreEqual(2.5, (double)s.GetCellContents("A1"), 1e-9);
        }
Example #6
0
        public void Test13()
        {
            TestableSpreadsheet s = new TestableSpreadsheet();

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

            Assert.AreEqual(3, f.Evaluate(x => 0), 1e-6);
        }
Example #7
0
        public void Test16()
        {
            TestableSpreadsheet s = new TestableSpreadsheet();

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