Exemplo n.º 1
0
        private void MainWindowModelOnConnectionStateChanged(object sender, ConnectionStateInfo connectionStateInfo)
        {
            string stateInfo = connectionStateInfo.ToString();

            if (Application.Current != null)
            {
                Application.Current.Dispatcher.Invoke(() => ConnectionLog.Add(stateInfo));
            }
            else
            {
                ConnectionLog.Add(stateInfo);
            }
        }
Exemplo n.º 2
0
        public void StateChangeHandling_WhenStateInfoFromModel_StateInfoAddedToConnectioLog()
        {
            var stateInfo           = new ConnectionStateInfo("test");
            var mainWindowModelMock = new Mock <IMainWindowModel>();

            mainWindowModelMock.Setup(x => x.Start(It.IsNotNull <ConnectionParameters>()))
            .Raises(x => x.ConnectionStateChanged += null, this, stateInfo);

            var mainWindowViewModel = new MainWindowViewModel(mainWindowModelMock.Object);

            mainWindowViewModel.StartClickCommand.Execute(null);

            Assert.AreEqual(1, mainWindowViewModel.ConnectionLog.Count);
            Assert.AreEqual(stateInfo.ToString(), mainWindowViewModel.ConnectionLog[0]);
        }