/// <summary> /// Returns the one SpreadsheetApplicationContext. /// </summary> public static SpreadsheetApplicationContext getAppContext() { if (appContext == null) { appContext = new SpreadsheetApplicationContext(); } return appContext; }
public void TestMethod12() { SpreadsheetApplicationContext.GetContext().IsUnitTest = true; // Prevents it from trying to create a Window. Controller controller = new Controller(this); CellValueBoxTextChange.Invoke("=(("); Assert.AreEqual(string.Empty, controller.SelectedCell.GetCellContents(controller.Spreadsheet)); }
public void TestMethod6() { _setSelectionRan = false; SpreadsheetApplicationContext.GetContext().IsUnitTest = true; // Prevents it from trying to create a Window. Controller controller = new Controller(this); Spreadsheet s = new Spreadsheet(); controller.ChangeSpreadsheet(s); CreateNew.Invoke(); Assert.IsTrue(_setSelectionRan); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Start an application context and run one form inside it SpreadsheetApplicationContext appContext = SpreadsheetApplicationContext.GetAppContext(); Form1 instance = new Form1(); appContext.RunForm(instance); if (args.Length > 0) { instance.openFile(args[0]); } Application.Run(appContext); }
public void TestMethod10() { _cells = new Dictionary <Tuple <int, int>, string>(); SpreadsheetApplicationContext.GetContext().IsUnitTest = true; // Prevents it from trying to create a Window. Controller controller = new Controller(this); Spreadsheet s = new Spreadsheet(); s.SetContentsOfCell("A1", "testing!"); controller.ChangeSpreadsheet(s); controller.HandleSave(TestSaveFilePath2); controller.HandleOpen(TestSaveFilePath2); //Test file exists and was open. Assert.IsTrue(File.Exists(TestSaveFilePath1)); Assert.AreEqual("test2", _title); Assert.AreEqual("testing!", controller.Spreadsheet.GetCellValue("A1")); }
/// <summary> /// Creates a new window with a fresh spreadsheet, running on the same thread as the current sheet /// </summary> /// <param name="sender">"new" menu button object that sent the event</param> /// <param name="e">Event to be handled</param> private void newToolStripMenuItem_Click(object sender, EventArgs e) { SpreadsheetApplicationContext.GetAppContext().RunForm(new Form1()); }