public void TestExport() { m_FileSystem = new DynamicMock(typeof(IFileSystem)); List <Context> selected = new List <Context>(); Context result = new Context(); result.Tokens.Add("a"); result.Tokens.Add("b"); result.Tokens.Add("c"); Context branch = result.Branch("b1"); branch.Tokens.Add("d"); selected.Add(result); IExporter exporter = new CsvExporter(); m_FileSystem.Expect("WriteAllText", @"c:\abc.csv", string.Format(".Word.;b1{0}abc;abcd{0}", Environment.NewLine)); exporter.Export(selected, @"c:\abc.csv", (IFileSystem)m_FileSystem.MockInstance); m_FileSystem.Verify(); }
public void TestGetColumn() { Project p = new Project(Whee.WordBuilder.Helpers.Random.Instance); Context c = new Context(); c.Tokens.Add("a"); c.Tokens.Add("b"); c.Tokens.Add("c"); Assert.AreEqual("abc", c.GetColumn("", p)); c.Mark("m1", "m1"); Assert.AreEqual("m1", c.GetColumn("!m1", p)); Context branch = c.Branch("b1"); branch.Tokens.Add("d"); Assert.AreEqual("abcd", c.GetColumn("b1", p)); branch.Mark("m2", "m2"); Assert.AreEqual("m2", c.GetColumn("b1.!m2", p)); Context branch2 = branch.Branch("b2"); branch2.Tokens.Add("e"); Assert.AreEqual("abcde", c.GetColumn("b1.b2", p)); }
public void TestBranch() { Context c = new Context(); Assert.AreEqual(0, c.Branches.Count); c.Tokens.Add("a"); Context branch = c.Branch("sub1"); Assert.AreEqual(1, c.Branches.Count); Assert.Contains("sub1", c.Branches.Keys); Assert.Contains("a", branch.Tokens); Assert.AreEqual("a", branch.ToString()); }
public void TestDetailsView() { List <Context> selected = new List <Context>(); Context result = new Context(); result.Tokens.Add("a"); result.Tokens.Add("b"); result.Tokens.Add("c"); Context branch = result.Branch("b1"); branch.Tokens.Add("d"); selected.Add(result); Expect.Once.On(m_DetailsTextViewHelper).Method("OnDocumentChanged").With(m_GeneratorController, string.Format("abc{0}\tb1: abcd", Environment.NewLine), Is.Anything); m_GeneratorController.OnTreeViewSelectionChanged(selected); m_Mockery.VerifyAllExpectationsHaveBeenMet(); }
public void TestDescription() { Context c = new Context(); c.Tokens.Add("a"); c.Tokens.Add("b"); c.Tokens.Add("c"); Assert.AreEqual("abc", c.Description("")); c.Mark("m1", "m1"); Assert.AreEqual(String.Format("abc{0}m1: m1", Environment.NewLine), c.Description("")); Context branch = c.Branch("b1"); branch.Tokens.Add("d"); Assert.AreEqual(String.Format("abc{0}m1: m1{0}\tb1: abcd", Environment.NewLine), c.Description("")); branch.Mark("m2", "m2"); Assert.AreEqual(String.Format("abc{0}m1: m1{0}\tb1: abcd{0}\tm2: m2", Environment.NewLine), c.Description("")); }
public void TestCopyAdvanced() { List <Context> selected = new List <Context>(); Context result = new Context(); result.Tokens.Add("a"); result.Tokens.Add("b"); result.Tokens.Add("c"); Context branch = result.Branch("b1"); branch.Tokens.Add("d"); selected.Add(result); Expect.Once.On(m_ResultViewHelper).Method("GetSelectedItems").Will(Return.Value(selected)); Expect.Once.On(m_ClipBoardHelper).Method("Copy").With(String.Format("abc{0}\tb1: abcd", Environment.NewLine)); m_GeneratorController.CopyDescription(); m_Mockery.VerifyAllExpectationsHaveBeenMet(); m_Mockery.VerifyAllExpectationsHaveBeenMet(); }
public void TestExport() { List <Context> selected = new List <Context>(); Context result = new Context(); result.Tokens.Add("a"); result.Tokens.Add("b"); result.Tokens.Add("c"); Context branch = result.Branch("b1"); branch.Tokens.Add("d"); selected.Add(result); Expect.Once.On(m_ResultViewHelper).Method("GetAllItems").Will(Return.Value(selected)); Expect.Once.On(m_ExportHelper).Method("Export"); m_GeneratorController.Export(m_ExportHelper, @"c:\abc.csv"); m_Mockery.VerifyAllExpectationsHaveBeenMet(); m_Mockery.VerifyAllExpectationsHaveBeenMet(); }