/// <summary> /// Saves this spreadsheet to a ".sprd" file locally to the user's computer. /// Utilizes Spreadsheet's xmlWriter in the Save method to write this spreadsheet's info to the disk /// </summary> /// <param name="sender">"Save As" option from the file menu</param> /// <param name="e"></param> private void saveToolStripMenuItem_Click(object sender, EventArgs e) { using (SaveFileDialog sfd = new SaveFileDialog()) { sfd.Title = "Save Spreadsheet Explorer"; sfd.FileName = fileName; sfd.DefaultExt = ".sprd"; sfd.Filter = "Spreadsheet|*.sprd|All Files|*.*"; if (sfd.ShowDialog() == DialogResult.OK) { fileName = sfd.FileName; if (sfd.FilterIndex == 1) //User chose option 1: ".sprd files only" is selected { sheet.Save(fileName.Substring(fileName.Length - 5).Equals(".sprd") ? fileName : fileName + ".sprd"); isChanged = false; } else { sheet.Save(fileName + ".sprd"); //Append ".sprd" if "All File Types" is selected isChanged = false; } } } }
/// <summary> /// Saves a spreadsheet to an existing file /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveToolStripMenuItem_Click(object sender, EventArgs e) { //If there is no valid path, run save as. Otherwise, save to the existing file path if (savePath == "") { saveAsToolStripMenuItem_Click(sender, e); } else { mainSpread.Save(savePath); } }
public void SaveTest4() { AbstractSpreadsheet ss = new Spreadsheet(); Set(ss, "A1", "hello"); Set(ss, "A2", "5.0"); Set(ss, "A3", "4.0"); Set(ss, "A4", "= A2 + A3"); StringWriter sw = new StringWriter(); ss.Save(sw); using (XmlReader reader = XmlReader.Create(new StringReader(sw.ToString()))) { int spreadsheetCount = 0; int cellCount = 0; while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "spreadsheet": Assert.IsTrue(new Regex(reader["IsValid"]).IsMatch("a4")); spreadsheetCount++; break; case "cell": string name = reader["name"]; string contents = reader["contents"]; if (name.Equals("A1")) { Assert.AreEqual("hello", contents); } else if (name.Equals("A2")) { Assert.AreEqual(5.0, Double.Parse(contents), 1e-9); } else if (name.Equals("A3")) { Assert.AreEqual(4.0, Double.Parse(contents), 1e-9); } else if (name.Equals("A4")) { contents = contents.Replace(" ", ""); Assert.AreEqual("=A2+A3", contents); } else { Assert.Fail(); } cellCount++; break; } } } Assert.AreEqual(1, spreadsheetCount); Assert.AreEqual(4, cellCount); } }
public void SaveTest6() { AbstractSpreadsheet ss = new Spreadsheet(s => true, s => s, "hello"); ss.Save("save4.txt"); Assert.AreEqual("hello", new Spreadsheet().GetSavedVersion("save4.txt")); }
/// <summary> /// Opens a save file dialogue and saves the model to a file /// </summary> private void Save() { try { // open file explorer SaveFileDialog saveFile = new SaveFileDialog { Filter = "Spreadsheet File (*.sprd)|*.sprd|All files (*.*)|*.*", Title = "Save " + window.WindowText, OverwritePrompt = true, FileName = window.WindowText }; // when ok is pressed and the file name is not empty if (saveFile.ShowDialog() == DialogResult.OK) { if (saveFile.FileName != "") { // get the file name and the file's absolute path saveFile.FileName = Path.GetFullPath(saveFile.FileName); window.WindowText = Path.GetFileName(saveFile.FileName); // save file using the absolute path sheet.Save(saveFile.FileName); } } } catch (SpreadsheetReadWriteException) { window.ShowErrorMessageBox("Problem occurred while saving the file"); } }
public void TestConstructor() { //just some stuff with filewriting Assert.IsTrue(sheet1.IsValid("any old string")); Assert.IsTrue(sheet1.Normalize("dead") == "dead"); Assert.IsTrue(sheet1.Version == "default"); //test 3 arg constructor sheet1 = new Spreadsheet(s => (s.Length >= 2) ? true : false, s => s.Replace(" ", ""), "version1"); Assert.IsTrue(sheet1.IsValid("A1")); Assert.IsFalse(sheet1.IsValid("A")); Assert.IsTrue(sheet1.Normalize("d e a d") == "dead"); Assert.IsTrue(sheet1.Version == "version1"); sheet1.SetContentsOfCell("A 1","loaded!"); string savePath = "save 1.xml"; sheet1.Save(savePath); sheet1 = new Spreadsheet( savePath, s => (s.Length >= 2) ? true : false, s => s.Replace(" ", ""), "version1"); Assert.AreEqual("loaded!",(string)sheet1.GetCellContents("A1")); }
public void SaveTest5() { AbstractSpreadsheet ss = new Spreadsheet(); ss.Save("save3.txt"); ss = new Spreadsheet("save3.txt", s => true, s => s, "version"); }
public void NewTest11() { Spreadsheet s = new Spreadsheet(x => true, x => x, "\"default\""); s.SetContentsOfCell("a1", "Text"); s.Save("..\\..\\..\\Test.xml"); string sversion = s.GetSavedVersion("..\\..\\..\\Test.xml"); Assert.AreEqual("\"default\"", sversion); }
public void SaveTest3() { AbstractSpreadsheet s1 = new Spreadsheet(); Set(s1, "A1", "hello"); s1.Save(@"X:\.win_my_documents\Tests\test3.xml"); s1 = new Spreadsheet("save1.txt", s => true, s => s, "default"); Assert.AreEqual("hello", s1.GetCellContents("A1")); }
public void MediumSave() { AbstractSpreadsheet ss = new Spreadsheet(); MediumSheet(ss); ss.Save("save7.txt"); ss = new Spreadsheet("save7.txt", s => true, s => s, "default"); VV(ss, "A1", 2.0, "A2", 2.0, "A3", 3.0, "A4", 4.0, "B1", 1.0, "B2", 12.0, "C1", 13.0); }
public void Changed3() { AbstractSpreadsheet ss = new Spreadsheet(); Assert.IsFalse(ss.Changed); Set(ss, "C1", "17.5"); Assert.IsTrue(ss.Changed); ss.Save(new StringWriter()); Assert.IsFalse(ss.Changed); }
public void TestChanged() { AbstractSpreadsheet sheety = new Spreadsheet(); Assert.AreEqual(false, sheety.Changed); sheety.SetContentsOfCell("A1", "4"); Assert.AreEqual(true, sheety.Changed); sheety.Save(@"C:\Users\Tim\Documents\Visual Studio 2015\XMLTESTS\test42.xml"); Assert.AreEqual(false, sheety.Changed); }
public void SaveTest1() { AbstractSpreadsheet s1 = new Spreadsheet(); Set(s1, "A1", "hello"); StringWriter sw = new StringWriter(); s1.Save(sw); s1 = new Spreadsheet(new StringReader(sw.ToString()), new Regex("")); Assert.AreEqual("hello", s1.GetCellContents("A1")); }
/// <summary> /// Will attempt to save the spreadsheet /// </summary> private void SaveSpreadsheet() { try { spreadsheet.Save(saveFileDialog.FileName); } catch (SpreadsheetReadWriteException ex) { MessageBox.Show(ex.Message, "Error"); } }
public void MediumSave() { AbstractSpreadsheet ss = new Spreadsheet(); MediumSheet(ss); StringWriter sw = new StringWriter(); ss.Save(sw); ss = new Spreadsheet(new StringReader(sw.ToString()), new Regex("")); VV(ss, "A1", 2.0, "A2", 2.0, "A3", 3.0, "A4", 4.0, "B1", 1.0, "B2", 12.0, "C1", 13.0); }
public void SaveTest1() { Regex r = new Regex("^.*$"); AbstractSpreadsheet sheet = new Spreadsheet(r); sheet.SetContentsOfCell("A1", "5"); sheet.SetContentsOfCell("A2", "5"); sheet.SetContentsOfCell("A3", "=A1+A2"); sheet.SetContentsOfCell("A4", "=A3+A2"); TextWriter t = File.CreateText("../../testing.xml"); sheet.Save(t); }
/// <summary> /// Saves a file to the users computer. /// </summary> private void SaveFile() { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "Spreadsheet File (*.sprd)| *.sprd | All Files (*.*)|*.*"; saveFileDialog1.ShowDialog(); if (saveFileDialog1.FileName != "") { s.Save(saveFileDialog1.FileName); filename = saveFileDialog1.FileName; } }
public void Changed() { // Make sure it starts false AbstractSpreadsheet s = new Spreadsheet(); Assert.IsFalse(s.Changed); // Modify a file, see if changed is true; Use SetContentsOfCell s.SetContentsOfCell("Z7", "1.5"); Assert.IsTrue(s.Changed); // Save a file after modifying, see if it switches back to false s.Save("changed_test.xml"); Assert.IsFalse(s.Changed); }
public void SaveTest1() { AbstractSpreadsheet ss = new Spreadsheet(); try { ss.Save(File.CreateText("q:\\missing\\save.txt")); } catch (IOException) { return; } Assert.Fail(); }
public void TestXMLFilez() { AbstractSpreadsheet sheety = new Spreadsheet(); sheety.SetContentsOfCell("A1", "=(1+1)*2"); sheety.SetContentsOfCell("B1", "69"); sheety.SetContentsOfCell("C1", "HI MOM"); sheety.Save(@"C:\Users\Tim\Documents\Visual Studio 2015\XMLTESTS\test42.xml"); AbstractSpreadsheet sheety2 = new Spreadsheet(@"C:\Users\Tim\Documents\Visual Studio 2015\XMLTESTS\test42.xml", s => true, s => s, "default"); Assert.AreEqual(sheety.GetCellContents("A1"), sheety2.GetCellContents("A1")); Assert.AreEqual(sheety.GetCellContents("B1"), sheety2.GetCellContents("B1")); Assert.AreEqual(sheety.GetCellContents("C1"), sheety2.GetCellContents("C1")); }
/// <summary> /// deals withe save event under the file menu. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveToolStripMenuItem_Click(object sender, EventArgs e) { // Displays a SaveFileDialog so the user can save the Image // assigned to file save. SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "sprd files (*.sprd)|*.sprd|All Files (*.*)|*.*"; saveFileDialog1.Title = "Save a sprd File"; saveFileDialog1.ShowDialog(); //file must have a valid name if (saveFileDialog1.FileName != "") { sheet.Save(saveFileDialog1.FileName); } }
public void ReadTest1() { Regex r = new Regex("^.*$"); AbstractSpreadsheet sheet = new Spreadsheet(r); sheet.SetContentsOfCell("A1", "5"); sheet.SetContentsOfCell("A2", "5"); sheet.SetContentsOfCell("A3", "=A1+A2"); TextWriter t = File.CreateText("../../testing1.xml"); sheet.Save(t); t.Close(); TextReader read = File.OpenText("../../testing1.xml"); AbstractSpreadsheet sheet1 = new Spreadsheet(read); }
public void Test52() { AbstractSpreadsheet s = new Spreadsheet(); s.SetContentsOfCell("A1", "=" + new Formula("A2+A3").ToString()); s.SetContentsOfCell("A2", "6"); s.SetContentsOfCell("A3", "=" + new Formula("A2+A4").ToString()); s.SetContentsOfCell("A4", "=" + new Formula("A2+A5").ToString()); s.SetContentsOfCell("A5", "5"); TextWriter dest = new StreamWriter("../../Test52.xml"); s.Save(dest); }
/// <summary> /// Helper method which opens the save dialog and lets the user save the spreadsheet. /// </summary> private void SaveCurrent() { // Displays a SaveFileDialog so the user can save the spreadsheet SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Spreadsheets|*.sprd|All Files|*.*"; sfd.DefaultExt = "sprd"; sfd.AddExtension = true; DialogResult res = sfd.ShowDialog(); if (res.Equals(DialogResult.OK) && sfd.FileName != "") { thisSheet.Save(sfd.FileName); } if (res.Equals(DialogResult.Cancel)) { sfd.Dispose(); } }
public void CreateSaveLoadSpreadsheet() { Spreadsheet sheet = new Spreadsheet(); sheet.SetContentsOfCell("D1", "=5"); sheet.SetContentsOfCell("C1", "=4.5"); sheet.SetContentsOfCell("E1", "apples"); sheet.SetContentsOfCell("G1", "-2"); sheet.SetContentsOfCell("H1", "-4"); sheet.SetContentsOfCell("F1", "= G1 + H1"); sheet.Save(@"MyXml2.xml"); Spreadsheet sheet2 = new Spreadsheet(@"MyXml2.xml", s => true, s => s, "default"); Assert.AreEqual(sheet2.GetCellContents("D1"), new Formula("5")); Assert.AreEqual(sheet2.GetCellContents("C1"), new Formula("4.5")); Assert.AreEqual(sheet2.GetCellContents("E1"), "apples"); Assert.AreEqual(sheet2.GetCellContents("G1"), (double)-2); Assert.AreEqual(sheet2.GetCellContents("H1"), (double)-4); Assert.AreEqual(sheet2.GetCellContents("F1"), new Formula("G1 + H1")); Assert.AreEqual(sheet2.GetCellValue("F1"), (double)-6); }
public void TestSave() { Spreadsheet ss = new Spreadsheet(); ss.SetContentsOfCell("A1", "3.0"); ss.SetContentsOfCell("B1", "2.0"); ss.SetContentsOfCell("C1", "4.0"); Assert.AreEqual(3.0, ss.GetCellValue("A1")); Assert.AreEqual(2.0, ss.GetCellValue("B1")); Assert.AreEqual(4.0, ss.GetCellValue("C1")); ss.SetContentsOfCell("D1", "=A1*2.0"); Assert.AreEqual(6.0, ss.GetCellValue("D1")); ss.SetContentsOfCell("F1", "=B1*C1"); Assert.AreEqual(8.0, ss.GetCellValue("F1")); ss.SetContentsOfCell("E1", "=D1*C1"); Assert.AreEqual(24.0, ss.GetCellValue("E1")); ss.SetContentsOfCell("G1", "=D1*E1"); ss.SetContentsOfCell("F1", "hello"); Assert.AreEqual(144.0, ss.GetCellValue("G1")); TextWriter tw = new StreamWriter("../../XMLFile1 - Copy.xml"); ss.Save(tw); StreamReader sr = new StreamReader("../../XMLFile1 - Copy.xml"); Spreadsheet s2 = new Spreadsheet(sr); Assert.AreEqual(3.0, s2.GetCellValue("A1")); Assert.AreEqual(2.0, s2.GetCellValue("B1")); Assert.AreEqual(4.0, s2.GetCellValue("C1")); Assert.AreEqual(24.0, s2.GetCellValue("E1")); Assert.AreEqual(144.0, s2.GetCellValue("G1")); Assert.AreEqual("hello", s2.GetCellValue("F1")); }
public void SaveTest8() { AbstractSpreadsheet ss = new Spreadsheet(); Set(ss, "A1", "hello"); Set(ss, "A2", "5.0"); Set(ss, "A3", "4.0"); Set(ss, "A4", "= A2 + A3"); ss.Save("save6.txt"); using (XmlReader reader = XmlReader.Create("save6.txt")) { int spreadsheetCount = 0; int cellCount = 0; bool A1 = false; bool A2 = false; bool A3 = false; bool A4 = false; string name = null; string contents = null; while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "spreadsheet": Assert.AreEqual("default", reader["version"]); spreadsheetCount++; break; case "cell": cellCount++; break; case "name": reader.Read(); name = reader.Value; break; case "contents": reader.Read(); contents = reader.Value; break; } } else { switch (reader.Name) { case "cell": if (name.Equals("A1")) { Assert.AreEqual("hello", contents); A1 = true; } else if (name.Equals("A2")) { Assert.AreEqual(5.0, Double.Parse(contents), 1e-9); A2 = true; } else if (name.Equals("A3")) { Assert.AreEqual(4.0, Double.Parse(contents), 1e-9); A3 = true; } else if (name.Equals("A4")) { contents = contents.Replace(" ", ""); Assert.AreEqual("=A2+A3", contents); A4 = true; } else { Assert.Fail(); } break; } } } Assert.AreEqual(1, spreadsheetCount); Assert.AreEqual(4, cellCount); Assert.IsTrue(A1); Assert.IsTrue(A2); Assert.IsTrue(A3); Assert.IsTrue(A4); } }
public void NewTest10() { Spreadsheet s = new Spreadsheet(x => true, x => x, "\"default\""); s.SetContentsOfCell("a1", "b1 + c1"); s.Save("..\\..\\..\\test3.xml"); }
public void SpreadsheetFourArgumentConstructorTest() { if (!File.Exists("fourarg.xml")) { Spreadsheet old = new Spreadsheet(TestValidToTrue, TestNormalizeToUpperCase, "2.2"); old.SetContentsOfCell("A1", "asdf"); old.SetContentsOfCell("B2", "23"); old.Save("fourarg.xml"); } Spreadsheet s = new Spreadsheet("fourarg.xml", TestValidToTrue, TestNormalizeToUpperCase, "2.2"); Assert.AreEqual(true, s.IsValid("a")); Assert.AreEqual("A", s.Normalize("a")); Assert.AreEqual("asdf", s.GetCellContents("A1")); Assert.AreEqual(23.0, s.GetCellContents("B2")); Assert.AreEqual(23.0, s.GetCellValue("B2")); Assert.AreEqual("2.2", s.Version); }
public void TestSavedVersion2() { string version = "10.2091.23"; Spreadsheet sheet = new Spreadsheet(x => true, s => s, version); sheet.SetContentsOfCell("a1", "hello"); string path = "savedVersion2.xml"; sheet.Save(path); Assert.AreEqual(version, sheet.GetSavedVersion(path)); }
public void TestSave2() { Spreadsheet sheet = new Spreadsheet(); sheet.SetContentsOfCell("a1", "12.03"); sheet.SetContentsOfCell("b2", "hello world!"); sheet.SetContentsOfCell("c3", "=4+17-3"); sheet.SetContentsOfCell("d4", "=x3"); sheet.Save("test2.xml"); }
public void TestRead3() { string path = "read3.xml"; Spreadsheet sheet = new Spreadsheet(); sheet.SetContentsOfCell("a1", "=1.5+4"); sheet.SetContentsOfCell("b2", "=a2-2.6"); sheet.SetContentsOfCell("c3", "=3.7*e5"); sheet.SetContentsOfCell("d4", "hil"); sheet.SetContentsOfCell("e5", "5.9"); sheet.Save(path); HashSet<string> original = (HashSet<string>)sheet.GetNamesOfAllNonemptyCells(); Spreadsheet sheet2 = new Spreadsheet(path, x => true, s => s, "default"); foreach (string s in original) { Assert.IsTrue(sheet.GetCellContents(s).Equals(sheet2.GetCellContents(s))); Assert.IsTrue(sheet.GetCellValue(s).Equals(sheet2.GetCellValue(s))); } }
public void TestRead1() { string path = "read1.xml"; Spreadsheet sheet = new Spreadsheet(); sheet.SetContentsOfCell("a1", "1.5"); sheet.SetContentsOfCell("b2", "2.6"); sheet.SetContentsOfCell("c3", "3.7"); sheet.SetContentsOfCell("d4", "4.8"); sheet.SetContentsOfCell("e5", "5.9"); sheet.Save(path); sheet = new Spreadsheet(path, x => true, s => s, "default"); }
public void SaveTest3() { AbstractSpreadsheet ss = new Spreadsheet(new Regex("^[b-zB-Z]+[0-9]+")); ss.SetContentsOfCell("B1", "5"); StringWriter sw = new StringWriter(); ss.Save(sw); ss = new Spreadsheet(new StringReader(sw.ToString())); try { ss.SetContentsOfCell("A1", "5"); } catch (InvalidNameException) { return; } Assert.Fail(); }
public void SaveTest1() { AbstractSpreadsheet s1 = new Spreadsheet(); Set(s1, "A1", "hello"); StringWriter sw = new StringWriter(); s1.Save(sw); s1 = new Spreadsheet(new StringReader(sw.ToString())); Assert.AreEqual("hello", s1.GetCellContents("A1")); }
public void SaveTest() { Spreadsheet target = new Spreadsheet(); // TODO: Initialize to an appropriate value string filename = string.Empty; // TODO: Initialize to an appropriate value target.Save(filename); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public void SaveTest8() { AbstractSpreadsheet ss = new Spreadsheet(); Set(ss, "A1", "hello"); Set(ss, "A2", "5.0"); Set(ss, "A3", "4.0"); Set(ss, "A4", "= A2 + A3"); ss.Save("save6.txt"); using (XmlReader reader = XmlReader.Create("save6.txt")) { int spreadsheetCount = 0; int cellCount = 0; bool A1 = false; bool A2 = false; bool A3 = false; bool A4 = false; string name = null; string contents = null; while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "spreadsheet": Assert.AreEqual("default", reader["version"]); spreadsheetCount++; break; case "cell": cellCount++; break; case "name": reader.Read(); name = reader.Value; break; case "contents": reader.Read(); contents = reader.Value; break; } } else { switch (reader.Name) { case "cell": if (name.Equals("A1")) { Assert.AreEqual("hello", contents); A1 = true; } else if (name.Equals("A2")) { Assert.AreEqual(5.0, Double.Parse(contents), 1e-9); A2 = true; } else if (name.Equals("A3")) { Assert.AreEqual(4.0, Double.Parse(contents), 1e-9); A3 = true; } else if (name.Equals("A4")) { contents = contents.Replace(" ", ""); Assert.AreEqual("=A2+A3", contents); A4 = true; } else Assert.Fail(); break; } } } Assert.AreEqual(1, spreadsheetCount); Assert.AreEqual(4, cellCount); Assert.IsTrue(A1); Assert.IsTrue(A2); Assert.IsTrue(A3); Assert.IsTrue(A4); } }
public void SaveTest() { string existing_path = @"..\..\..\SpreadSheetTests\validspreadsheet.xml"; // the .. means up a directory Spreadsheet target = new Spreadsheet(existing_path, s => true, s => s.ToUpper(), "dan1"); Assert.AreEqual(2.0, (double)target.GetCellValue("a2")); target.Save(@"output22.xml"); var output = File.ReadAllText("output22.xml"); Assert.AreEqual("<?xml version=\"1.0\" encoding=\"utf-8\"?><spreadsheet version=\"dan1\"><cell><name>A1</name><contents>2</contents></cell><cell><name>A2</name><contents>=A1</contents></cell></spreadsheet>", output); }
public void NewTest13() { Spreadsheet s = new Spreadsheet(x => true, x => x, "default"); s.SetContentsOfCell("a1", "Text"); s.Save(null); }
public void TestGetChanged1() { string path = "GetChanged1.xml"; Spreadsheet sheet = new Spreadsheet(); Assert.IsTrue(!sheet.Changed); sheet.SetContentsOfCell("a1", "hello"); Assert.IsTrue(sheet.Changed); sheet.Save(path); Assert.IsTrue(!sheet.Changed); }
public void SaveTest5() { AbstractSpreadsheet ss = new Spreadsheet(); Set(ss, "A1", "hello"); Set(ss, "A2", "5.0"); Set(ss, "A3", "4.0"); Set(ss, "A4", "= A2 + A3"); StringWriter sw = new StringWriter(); ss.Save(sw); using (XmlReader reader = XmlReader.Create(new StringReader(sw.ToString()))) { int spreadsheetCount = 0; int cellCount = 0; while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "spreadsheet": Assert.IsTrue(new Regex(reader["IsValid"]).IsMatch("a4")); spreadsheetCount++; break; case "cell": string name = reader["name"]; string contents = reader["contents"]; if (name.Equals("A1")) { Assert.AreEqual("hello", contents); } else if (name.Equals("A2")) { Assert.AreEqual(5.0, Double.Parse(contents), 1e-9); } else if (name.Equals("A3")) { Assert.AreEqual(4.0, Double.Parse(contents), 1e-9); } else if (name.Equals("A4")) { contents = contents.Replace(" ", ""); Assert.AreEqual("=A2+A3", contents); } else Assert.Fail(); cellCount++; break; } } } Assert.AreEqual(1, spreadsheetCount); Assert.AreEqual(4, cellCount); } }
public void TestRead2() { string path = "read2.xml"; Spreadsheet sheet = new Spreadsheet(); sheet.SetContentsOfCell("a1", "1.5"); sheet.SetContentsOfCell("b2", "2.6"); sheet.SetContentsOfCell("c3", "3.7"); sheet.SetContentsOfCell("d4", "4.8"); sheet.SetContentsOfCell("e5", "5.9"); sheet.Save(path); HashSet<string> original = (HashSet<string>)sheet.GetNamesOfAllNonemptyCells(); sheet = new Spreadsheet(path, x => true, s => s, "default"); HashSet<string> output = (HashSet<string>)sheet.GetNamesOfAllNonemptyCells(); Assert.IsTrue(original.SetEquals(output)); }
public void MediumSave() { AbstractSpreadsheet ss = new Spreadsheet(); MediumSheet(ss); StringWriter sw = new StringWriter(); ss.Save(sw); ss = new Spreadsheet(new StringReader(sw.ToString())); VV(ss, "A1", 2.0, "A2", 2.0, "A3", 3.0, "A4", 4.0, "B1", 1.0, "B2", 12.0, "C1", 13.0); }
public void TestSave1() { Spreadsheet sheet = new Spreadsheet(); sheet.SetContentsOfCell("a1", "12.03"); sheet.Save("test1.xml"); }
public void SaveTest1() { AbstractSpreadsheet ss = new Spreadsheet(); ss.Save("q:\\missing\\save.txt"); }
public void TestSavedVersion1() { Spreadsheet sheet = new Spreadsheet(); sheet.SetContentsOfCell("a1", "hello"); string path = "savedVersion1.xml"; sheet.Save(path); string version = "default"; Assert.AreEqual(version, sheet.GetSavedVersion(path)); }
public void SaveTest5() { AbstractSpreadsheet ss = new Spreadsheet(); ss.Save("save3.txt"); ss = new Spreadsheet("save3.txt", s => true, s => s, "version"); }
public void MediumSave() { AbstractSpreadsheet ss = new Spreadsheet(); MediumSheet(ss); ss.Save("save7.txt"); ss = new Spreadsheet("save7.txt", s => true, s => s, "default"); VV(ss, "A1", 2.0, "A2", 2.0, "A3", 3.0, "A4", 4.0, "B1", 1.0, "B2", 12.0, "C1", 13.0); }
public void SaveExistingSpreadsheetTest() { Spreadsheet s = new Spreadsheet(); s.SetContentsOfCell("a1", "2"); s.Save("existingTest.xml"); Assert.AreEqual(true, File.Exists("existingTest.xml")); s.SetContentsOfCell("a1", "35"); s.Save("existingTest.xml"); Assert.AreEqual(true, File.Exists("existingTest.xml")); }
public void SaveTest3() { AbstractSpreadsheet s1 = new Spreadsheet(); Set(s1, "A1", "hello"); s1.Save("save1.txt"); s1 = new Spreadsheet("save1.txt", s => true, s => s, "default"); Assert.AreEqual("hello", s1.GetCellContents("A1")); }
/// <summary> /// Saves the current spreadsheet. /// </summary> /// <param name="fileName">File to save</param> public void SaveSpreadsheet(string fileName) { s.Save(fileName); }
public void SaveTest6() { AbstractSpreadsheet ss = new Spreadsheet(s => true, s => s, "hello"); ss.Save("save4.txt"); Assert.AreEqual("hello", new Spreadsheet().GetSavedVersion("save4.txt")); }
public void NewTest9() { Spreadsheet s = new Spreadsheet(x => true, x => x, "default"); s.SetContentsOfCell("a1", "25"); s.Save("..\\..\\..\\test2.xml"); }
public void Changed3() { AbstractSpreadsheet ss = new Spreadsheet(); Assert.IsFalse(ss.Changed); Set(ss, "C1", "17.5"); Assert.IsTrue(ss.Changed); ss.Save(new StringWriter()); Assert.IsFalse(ss.Changed); }
public void SaveTest1() { AbstractSpreadsheet ss = new Spreadsheet(); ss.Save("q:\\missing\\save.txt"); }