public WcPresenter(WcModel model) { this.model = model; this.InputLine = String.Empty; this.DoClear = new RelayCommand(() => model.ClearResults(), p => model.Bind.History.Count > 0); this.DoCount = new RelayCommand <string> (a => CountWords(a)); }
public void WcParse() { var wc = new WcModel(); int k1 = wc.Parse("a bb ccc"); Assert.AreEqual(3, k1); Assert.AreEqual(1, wc.Bind.History.Count); }
private void WcController_Loaded(object sender, RoutedEventArgs e) { // Best practice is to create the model here - after the app has started. // This allows showing splash or status while model is spinning up. wcModel = new WcModel(); viewFactory.Create(this, wcModel.Bind); DataContext = wcModel.Bind; // Process command line arguments: inputBox.Text = string.Join(" ", args); }
public void VmInput() { var wc = new WcModel(); var pr = new WcPresenter(wc); Assert.AreEqual(0, pr.WC.History.Count); wc.Parse("aaa bb c"); Assert.IsTrue(pr.WC.History[0].StartsWith("3 words")); }
// MVVM purists say this file should contain no code-behind. // However these application startup bits seem necessary here: // - Spin up the model before the GUI for splash & status. // - Initialize DataContext with an argument. // - Process command line arguments. private void WcController_Loaded(object sender, RoutedEventArgs e) { WcPresenter presenter; // Best practice is to create the model here - after the app has started. // This allows showing splash or status while model is spinning up. var model = new WcModel(); // Initialize DataContext here because it can't be created in XAML with an argument. DataContext = presenter = new WcPresenter(model); // Process command line arguments: presenter.InputLine = string.Join(" ", Environment.GetCommandLineArgs()); }
public void WcCtor() { var wc = new WcModel(); Assert.AreEqual(0, wc.Bind.History.Count); }