Exemple #1
0
 protected override void OnStartup(StartupEventArgs e)
 {
     MainWindow mainWindow = new MainWindow();
     MainWindowModel mainView = new MainWindowModel();
     mainWindow.DataContext = mainView;
     mainWindow.Show();
 }
 public void MainWindowVM_DeleteChord_RunsDocumentDeleteChordMethod()
 {
     MainWindowModel model = new MainWindowModel();
     var doc = new FakeDocumentViewModel(model);
     model.Documents.Add(doc);
     model.DeleteChord.Execute(null);
     Assert.IsTrue(doc.DeleteSelectedChordWasRun,
         "The method on DocumentVM should have run.");
 }
 public void MainWindowVM_CloseDocument_ClosesDocument()
 {
     var model = new MainWindowModel();
     var document = new DocumentViewModel(model);
     model.Documents.Add(document);
     model.CloseDocument(document);
     Assert.IsTrue(!model.Documents.Contains(document),
         "The Documents collection should not contain this document now.");
 }
 public void MainWindowVM_NewDocument_AddsAndSelectsNewDocument()
 {
     var model = new MainWindowModel();
     model.NewDocument.Execute(null);
     var doc = model.Documents[0];
     var added = model.Documents.Count > 0;
     var selected = (model.DocumentsView.CurrentItem == doc);
     Assert.IsTrue(added, "The document should be added to the collection.");
     Assert.IsTrue(selected, "The document should be selected.");
 }
 public void MainWindowVM_Insert_InsertsChordLine()
 {
     MainWindowModel model = new MainWindowModel();
     var doc = new DocumentViewModel();
     model.Documents.Add(doc);
     model.InsertCommand.Execute(null);
     var selectedDoc = (model.DocumentsView.CurrentItem as DocumentViewModel);
     var lineAdded = (selectedDoc.ChordLines.Count == 1);
     Assert.IsTrue(lineAdded, "The line should have been added.");
 }
 public void MainWindowVM_TransposeDown_AllChordsWereTransposed()
 {
     var model = new MainWindowModel();
     var doc = new DocumentViewModel(model);
     var chordLine = new ChordLine();
     var chordA = new StubbChord();
     var chordB = new StubbChord();
     chordLine.Chords.Add(chordA);
     chordLine.Chords.Add(chordB);
     doc.ChordLines.Add(chordLine);
     model.Documents.Add(doc);
     model.TransposeDown.Execute(null);
     var wasTransposed = (chordA.WasTransposedDown && chordB.WasTransposedDown);
     Assert.IsTrue(wasTransposed, "All chords should have been transposed");
 }
 public FakeDocumentViewModel(MainWindowModel model)
     : base(model)
 {
 }