예제 #1
0
 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));
 }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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"));
        }
예제 #5
0
        // 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());
        }
예제 #6
0
        public void WcCtor()
        {
            var wc = new WcModel();

            Assert.AreEqual(0, wc.Bind.History.Count);
        }