public void VerifyRunEperimentCanExecute() { Assert.IsFalse(this.viewModel.CallRunMethodCommand.CanExecute(null)); this.dstController.Setup(c => c.IsSessionOpen).Returns(true); this.viewModel = new DstBrowserHeaderViewModel(this.dstController.Object, this.statusBarViewModel.Object, this.navigationService.Object); Assert.IsTrue(this.viewModel.CallRunMethodCommand.CanExecute(null)); this.viewModel.SelectedStepping = 0; Assert.IsFalse(this.viewModel.CallRunMethodCommand.CanExecute(null)); this.viewModel.SelectedStepping = 0.1; this.viewModel.SelectedStopStep = 0; Assert.IsFalse(this.viewModel.CallRunMethodCommand.CanExecute(null)); }
public void VerifyCallResetMethodCommand() { Assert.IsFalse(this.viewModel.CallResetMethodCommand.CanExecute(null)); this.dstController.Setup(c => c.IsSessionOpen).Returns(true); this.viewModel = new DstBrowserHeaderViewModel(this.dstController.Object, this.statusBarViewModel.Object, this.navigationService.Object); Assert.IsTrue(this.viewModel.CallResetMethodCommand.CanExecute(null)); this.navigationService.Setup(x => x.ShowDxDialog <DXDialogWindow>()).Returns(true); this.dstController.Setup(x => x.CallServerMethod("method_reset")).Returns(default(IList <object>)); this.viewModel.Reset(); this.dstController.Setup(x => x.CallServerMethod("method_reset")).Returns(new List <object>()); this.viewModel.Reset(); this.navigationService.Setup(x => x.ShowDxDialog <DXDialogWindow>()).Returns(false); this.viewModel.Reset(); this.navigationService.Setup(x => x.ShowDxDialog <DXDialogWindow>()).Returns(new bool?()); this.viewModel.Reset(); this.viewModel.Reset(false); this.navigationService.Setup(x => x.ShowDxDialog <DXDialogWindow>()).Throws <InvalidOperationException>(); Assert.DoesNotThrow(() => this.viewModel.Reset()); this.statusBarViewModel.Verify(x => x.Append(It.IsAny <string>(), StatusBarMessageSeverity.Error), Times.Exactly(2)); this.statusBarViewModel.Verify(x => x.Append(It.IsAny <string>(), StatusBarMessageSeverity.Info), Times.Exactly(2)); this.dstController.Verify(x => x.ResetVariables(), Times.Exactly(2)); this.dstController.Verify(x => x.ReTransferMappedThingsToDst(), Times.Exactly(2)); this.dstController.Verify(x => x.CallServerMethod("method_reset"), Times.Exactly(3)); }
public void Setup() { RxApp.MainThreadScheduler = Scheduler.CurrentThread; this.dstController = new Mock <IDstController>(); this.statusBarViewModel = new Mock <IStatusBarControlViewModel>(); this.statusBarViewModel.Setup(x => x.Append(It.IsAny <string>(), StatusBarMessageSeverity.Error)); this.statusBarViewModel.Setup(x => x.Append(It.IsAny <string>(), StatusBarMessageSeverity.Info)); this.dstController.Setup(x => x.IsSessionOpen).Returns(false); this.dstController.Setup(x => x.AddSubscription(It.IsAny <ReferenceDescription>())); this.dstController.Setup(x => x.ReadNode(It.IsAny <ReferenceDescription>())).Returns(new DataValue(.5)); this.dstController.Setup(x => x.Variables).Returns( new List <(ReferenceDescription Reference, DataValue Value)>() { (new ReferenceDescription() { NodeId = new ExpandedNodeId(Guid.NewGuid()), DisplayName = new LocalizedText("", "DummyVariable0") }, new DataValue()), (new ReferenceDescription() { NodeId = new ExpandedNodeId(Guid.NewGuid()), DisplayName = new LocalizedText("", "DummyVariable1") }, new DataValue()), (new ReferenceDescription() { NodeId = new ExpandedNodeId(Guid.NewGuid()), DisplayName = new LocalizedText("", "DummyVariable2") }, new DataValue()), }); this.dstController.Setup(x => x.References) .Returns(new List <ReferenceDescription>() { new ReferenceDescription() { BrowseName = new QualifiedName("TSTOP") }, new ReferenceDescription() { BrowseName = new QualifiedName("CINT") } }); this.dstController.Setup(x => x.WriteToDst(It.IsAny <NodeId>(), It.IsAny <double>())).Returns(true); this.dstController.Setup(x => x.ServerAddress).Returns("dummyAddress"); this.dstController.Setup(x => x.RefreshInterval).Returns(500); this.dstController.Setup(x => x.GetServerStartTime()).Returns(new DateTime(2021, 1, 1)); this.dstController.Setup(x => x.GetCurrentServerTime()).Returns(new DateTime(2021, 1, 3)); this.dstController.Setup(x => x.TimeNodeId).Returns(new NodeId(Guid.NewGuid())); this.dstController.Setup(x => x.GetNextExperimentStep()); this.navigationService = new Mock <INavigationService>(); this.navigationService.Setup(x => x.ShowDxDialog <DXDialogWindow>()).Returns(true); this.viewModel = new DstBrowserHeaderViewModel(this.dstController.Object, this.statusBarViewModel.Object, this.navigationService.Object); }