コード例 #1
0
        public void Test1()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireCellContentsChange("A1", "CS 1410");
            stub.FireCellContentsChange("A2", "CS 2420");
            stub.FireCellContentsChange("A3", "CS 3500");
            stub.FireCellContentsChange("A4", "CS 3810");

            stub.FireCellSelected(0, 0);
            Assert.AreEqual("A1", stub.CurrentCellName);
            Assert.AreEqual("CS 1410", stub.CurrentCellContents);
            Assert.AreEqual("CS 1410", stub.CurrentCellValue);

            stub.FireCellSelected(0, 1);
            Assert.AreEqual("A2", stub.CurrentCellName);
            Assert.AreEqual("CS 2420", stub.CurrentCellContents);
            Assert.AreEqual("CS 2420", stub.CurrentCellValue);

            stub.FireCellSelected(0, 2);
            Assert.AreEqual("A3", stub.CurrentCellName);
            Assert.AreEqual("CS 3500", stub.CurrentCellContents);
            Assert.AreEqual("CS 3500", stub.CurrentCellValue);

            stub.FireCellSelected(0, 3);
            Assert.AreEqual("A4", stub.CurrentCellName);
            Assert.AreEqual("CS 3810", stub.CurrentCellContents);
            Assert.AreEqual("CS 3810", stub.CurrentCellValue);

            stub.FireCloseEvent();
            Assert.IsTrue(stub.CalledDoClose);
            Assert.IsTrue(stub.CalledAskSave);
            Assert.IsFalse(stub.CalledOpenNew);
        }
コード例 #2
0
        public void Test2()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireCellContentsChange("A1", "11");
            stub.FireCellContentsChange("A2", "2");
            stub.FireCellContentsChange("A3", "=A1 * A2");
            stub.FireCellContentsChange("A4", "22");

            stub.FireCellSelected(0, 0);
            Assert.AreEqual("A1", stub.CurrentCellName);
            Assert.AreEqual("11", stub.CurrentCellContents.ToString());
            Assert.AreEqual(11.0, stub.CurrentCellValue);

            stub.FireCellSelected(0, 1);
            Assert.AreEqual("A2", stub.CurrentCellName);
            Assert.AreEqual("2", stub.CurrentCellContents.ToString());
            Assert.AreEqual(2.0, stub.CurrentCellValue);

            stub.FireCellSelected(0, 2);
            Assert.AreEqual("A3", stub.CurrentCellName);
            Assert.AreEqual("A1*A2", stub.CurrentCellContents.ToString());
            Assert.AreEqual(22.0, stub.CurrentCellValue);

            stub.FireCellSelected(0, 3);
            Assert.AreEqual("A4", stub.CurrentCellName);
            Assert.AreEqual("22", stub.CurrentCellContents.ToString());
            Assert.AreEqual(22.0, stub.CurrentCellValue);

            stub.FireCloseEvent();
            Assert.IsTrue(stub.CalledDoClose);
            Assert.IsTrue(stub.CalledAskSave);
            Assert.IsFalse(stub.CalledOpenNew);
        }
コード例 #3
0
        public void Test5()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireCellContentsChange("A1", "CS 1410");
            stub.FireCellContentsChange("A2", "CS 2420");
            stub.FireCellContentsChange("A3", "CS 3500");
            stub.FireCellContentsChange("A4", "CS 3810");

            stub.FireSaveEvent("savedSpreadsheet1.xml");
            Assert.IsFalse(stub.DidSendMessage);
        }
コード例 #4
0
        public void Test3()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireCellContentsChange("A1", "=2*/22");
            Assert.IsTrue(stub.DidSendMessage);
        }