コード例 #1
0
ファイル: ControllerTests.cs プロジェクト: EricSM/Spreadsheet
        public void TestClose()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireCloseEvent();
            Assert.IsTrue(stub.CalledDoClose);
        }
コード例 #2
0
ファイル: ControllerTests.cs プロジェクト: EricSM/Spreadsheet
        public void TestSave1()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireSaveEvent(null);
            Assert.AreEqual(stub.Message.Substring(0, 20), "Unable to save file\n");
        }
コード例 #3
0
        public void FileChosenEvent02()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            // IOException
            stub.FireFileChosenEvent("../../InvalidFormatSheet.ss");
            Assert.IsTrue(stub.CalledFileChosenEvent);
        }
コード例 #4
0
        public void FileChosenEvent04()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            // Spreadsheet Read Exception
            stub.FireFileChosenEvent("");
            Assert.IsTrue(stub.CalledFileChosenEvent);
        }
コード例 #5
0
        public void TestOpenFile1()
        {
            SpreadsheetViewStub stub = new SpreadsheetViewStub();

            stub.spreadSheetPanel = new SpreadsheetPanel();
            Controller controller = new Controller(stub);

            stub.FireFileChosenEvent("../../NotRealFile.ss");
            Assert.IsTrue(stub.Message.StartsWith("Unable"));
        }
コード例 #6
0
        public void CalledDoClose02()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireFileChosenEvent("../../demo1.ss");

            stub.FireCloseEvent();
            Assert.IsTrue(stub.CalledDoClose);
        }
コード例 #7
0
        public void TestSaveAndTitle()
        {
            SpreadsheetViewStub stub = new SpreadsheetViewStub();

            stub.spreadSheetPanel = new SpreadsheetPanel();
            Controller controller = new Controller(stub);

            stub.FireFileSaveEvent("../../testing.ss");
            Assert.AreEqual(stub.Title, "../../testing.ss");
        }
コード例 #8
0
        public void TestHelpName()
        {
            SpreadsheetViewStub stub = new SpreadsheetViewStub();

            stub.spreadSheetPanel = new SpreadsheetPanel();
            Controller controller = new Controller(stub);

            stub.FireHelpEvent();
            Assert.IsTrue(stub.Message.Equals("Click on a cell to select it.\nEnter desired contents of cell into \"Contents\" box and press enter to apply."));
        }
コード例 #9
0
        public void TestSelectionChange()
        {
            SpreadsheetViewStub stub = new SpreadsheetViewStub();

            stub.spreadSheetPanel = new SpreadsheetPanel();
            Controller controller = new Controller(stub);

            stub.FireSelectionEvent(stub.spreadSheetPanel);
            Assert.AreEqual(null, stub.Name);
        }
コード例 #10
0
        public void TestNewEvent()
        {
            SpreadsheetViewStub stub = new SpreadsheetViewStub();

            stub.spreadSheetPanel = new SpreadsheetPanel();
            Controller controller = new Controller(stub);

            stub.FireNewEvent();
            Assert.IsTrue(stub.CalledOpenNew);
        }
コード例 #11
0
ファイル: ControllerTests.cs プロジェクト: EricSM/Spreadsheet
        public void TestSave2()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireSaveEvent("spreadsheet2.ss");
            Assert.IsFalse(stub.Changed);
            Assert.AreEqual(stub.Message, null);
            Assert.AreEqual(stub.Title, "spreadsheet2.ss");
        }
コード例 #12
0
        public void TestContentsBox()
        {
            SpreadsheetViewStub stub = new SpreadsheetViewStub();

            stub.spreadSheetPanel = new SpreadsheetPanel();
            Controller controller = new Controller(stub);

            stub.FireContentsEvent();
            Assert.AreEqual("Cannot change cell contents to " + null + " because: " + "Value cannot be null.", stub.Message);
        }
コード例 #13
0
        public void TestOpenFile()
        {
            SpreadsheetViewStub stub = new SpreadsheetViewStub();

            stub.spreadSheetPanel = new SpreadsheetPanel();
            Controller controller = new Controller(stub);

            stub.FireFileChosenEvent("../../testing1.ss");
            Assert.AreEqual("../../testing1.ss", stub.Title);
            Assert.AreEqual(stub.Contents, "=A2");
        }
コード例 #14
0
        public void XClose01()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireFileChosenEvent("../../demo1.ss");
            Assert.AreEqual("../../demo1.ss", stub.Title);

            stub.FireClosingForm(new FormClosingEventArgs(new CloseReason(), true));
            Assert.IsTrue(stub.CalledClosingForm);
        }
コード例 #15
0
        public void KeyPress01()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireFileChosenEvent("../../demo1.ss");
            Assert.AreEqual("../../demo1.ss", stub.Title);

            stub.FireKeyPressedEvent('\r', "A1", "Doubles");
            Assert.IsTrue(stub.CalledKeyPressedEvent);
        }
コード例 #16
0
        public void EvaluateButton01()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireFileChosenEvent("../../demo1.ss");
            Assert.AreEqual("../../demo1.ss", stub.Title);

            stub.FireEvaluateClicked("A1", "Doubles");
            Assert.IsTrue(stub.CalledEvaluateClick);
        }
コード例 #17
0
        public void SaveFile01()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireFileChosenEvent("../../demo1.ss");
            Assert.AreEqual("../../demo1.ss", stub.Title);

            stub.FireSaveEvent("../../demo1.ss");
            Assert.IsTrue(stub.CalledSaveEvent);
        }
コード例 #18
0
ファイル: ControllerTests.cs プロジェクト: EricSM/Spreadsheet
        public void TestSelectionChanged()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireSelectionChangedEvent();

            Assert.AreEqual(stub.CellName, "A1");
            Assert.AreEqual(stub.CellValue, string.Empty);
            Assert.AreEqual(stub.CellContent, string.Empty);
        }
コード例 #19
0
ファイル: ControllerTests.cs プロジェクト: EricSM/Spreadsheet
        public void TestUpdate2()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.CellName = "A1";
            stub.FireUpdateEvent("10");
            stub.FireUpdateEvent("=a1");

            Assert.AreEqual(stub.Message.Substring(0, 8), "Error: \n");
            Assert.AreEqual(stub.CellContent, "10");
        }
コード例 #20
0
        public void HowTo01()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireFileChosenEvent("../../demo1.ss");
            Assert.AreEqual("../../demo1.ss", stub.Title);

            stub.FireHowToEvent();
            Assert.IsTrue(stub.CalledHowTo);
            Assert.IsTrue(stub.CalledMessage);
        }
コード例 #21
0
ファイル: ControllerTests.cs プロジェクト: EricSM/Spreadsheet
        public void TestSetCell()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.SetCell(3, 4, "10");

            Assert.IsTrue(stub.CalledSetCell);
            Assert.AreEqual(stub.Col, 3);
            Assert.AreEqual(stub.Row, 4);
            Assert.AreEqual(stub.CellContent, "10");
        }
コード例 #22
0
        public void TestContentsBox2()
        {
            SpreadsheetViewStub stub = new SpreadsheetViewStub();

            stub.spreadSheetPanel = new SpreadsheetPanel();
            Controller controller = new Controller(stub);

            stub.FireFileChosenEvent("../../testing1.ss");
            stub.Contents = "2";
            stub.FireContentsEvent();
            Assert.AreEqual("2", stub.Value);
        }
コード例 #23
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);
        }
コード例 #24
0
ファイル: ControllerTests.cs プロジェクト: EricSM/Spreadsheet
        public void TestUpdate1()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.CellName = "A1";
            stub.FireUpdateEvent("10");

            Assert.AreEqual(stub.Row, 0);
            Assert.AreEqual(stub.Col, 0);
            Assert.AreEqual(stub.CellValue, "10");
            Assert.AreEqual(stub.CellContent, "10");
            Assert.IsTrue(stub.Changed);
        }
コード例 #25
0
        public void SaveFile04()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireFileChosenEvent("../../demo1.ss");
            Assert.AreEqual("../../demo1.ss", stub.Title);

            SaveFileDialog sfd = new SaveFileDialog();

            sfd.FileName = ".../.../SaveAs02.ss";

            stub.FireSaveAsEvent(sfd);
            Assert.IsTrue(stub.CalledSaveAsEvent);
        }
コード例 #26
0
        public void SaveFile05()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireFileChosenEvent("../../demo1.ss");
            Assert.AreEqual("../../demo1.ss", stub.Title);

            // Make a change
            stub.FireEvaluateClicked("A2", "4");

            // Save the file
            stub.FireSaveEvent("../../demo1.ss");
            Assert.IsTrue(stub.CalledSaveEvent);
        }
コード例 #27
0
        public void XClose03()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireFileChosenEvent("../../demo1.ss");
            Assert.AreEqual("../../demo1.ss", stub.Title);

            // Make a change
            stub.FireEvaluateClicked("A2", "4");

            // Set dialog selection to cancel (save warning)
            stub.customSetDialogResult = DialogResult.Yes;
            stub.FireClosingForm(new FormClosingEventArgs(new CloseReason(), true));
            Assert.IsTrue(stub.CalledClosingForm);
        }
コード例 #28
0
        public void TestXClose()
        {
            SpreadsheetViewStub stub = new SpreadsheetViewStub();

            stub.spreadSheetPanel = new SpreadsheetPanel();
            Controller controller = new Controller(stub);

            stub.FireFileChosenEvent("../../testing1.ss");
            stub.Contents = "2";
            stub.FireContentsEvent();
            FormClosingEventArgs e;

            e = new FormClosingEventArgs(CloseReason.UserClosing, true);
            stub.FireXCloseEvent(e);
            Assert.AreEqual(true, e.Cancel);
        }
コード例 #29
0
ファイル: ControllerTests.cs プロジェクト: EricSM/Spreadsheet
        public void TestConstructor()
        {
            SpreadsheetViewStub stub        = new SpreadsheetViewStub();
            Spreadsheet         spreadsheet = new Spreadsheet();

            spreadsheet.SetContentsOfCell("a1", "=10");

            Controller controller = new Controller(stub, spreadsheet, "test.ss");

            Assert.IsTrue(stub.CalledSetCell);
            Assert.IsFalse(stub.Changed);
            Assert.AreEqual(stub.CellName, "A1");
            Assert.AreEqual(stub.Title, "test.ss");
            Assert.AreEqual(stub.CellContent, "=10");
            Assert.AreEqual(stub.CellValue, "10");
        }
コード例 #30
0
        public void EvaluateButton02()
        {
            SpreadsheetViewStub stub       = new SpreadsheetViewStub();
            Controller          controller = new Controller(stub);

            stub.FireFileChosenEvent("../../demo1.ss");
            Assert.AreEqual("../../demo1.ss", stub.Title);

            //Formula Format Exception
            stub.FireEvaluateClicked("E1", "=Z101");
            Assert.IsTrue(stub.CalledEvaluateClick);
            Assert.IsTrue(stub.CalledMessage);

            //Circular Exception
            stub.FireEvaluateClicked("A2", "=B2");
            Assert.IsTrue(stub.CalledEvaluateClick);
            Assert.IsTrue(stub.CalledMessage);
        }