public void SearchModel_Constructor_Validate() { const string expectedDisplayName = "SearchViewDisplayName"; var mockEventAggregator = new Mock <IEventAggregator>(); var searchViewModel = new MockSearchViewModel { DisplayName = expectedDisplayName }; var mockView = new Mock <IView>(); var mockAuthorizeCommand = new Mock <IAuthorizeCommand>(); var mockShellViewModel = new Mock <IShellViewModel>(); mockShellViewModel.Setup(shellViewModel => shellViewModel.SaveCommand).Returns(mockAuthorizeCommand.Object); SearchModel searchModel = null; using (searchModel = new SearchModel(mockEventAggregator.Object, searchViewModel, mockView.Object, mockShellViewModel.Object)) { searchModel.HelpText = "test"; Assert.IsNotNull(searchModel.ViewModel); Assert.IsNotNull(searchModel.View); Assert.IsFalse(searchModel.HasVariables); Assert.IsFalse(searchModel.HasDebugOutput); Assert.IsFalse(searchModel.IsDirty); Assert.AreEqual(searchModel.View, searchModel.GetView()); Assert.AreEqual(expectedDisplayName, searchModel.DisplayName); Assert.AreEqual("Search", searchModel.ResourceType); Assert.AreEqual("test", searchModel.HelpText); var doDeactivateCalled = searchModel.DoDeactivate(false); Assert.IsTrue(doDeactivateCalled); Assert.IsTrue(searchViewModel.HelpCalled); searchViewModel.TestPropertyChangedEvent("DisplayName"); mockShellViewModel.Verify(shellViewModel => shellViewModel.SaveCommand, Times.Once); } mockEventAggregator.Verify(o => o.Unsubscribe(searchModel), Times.AtLeastOnce); }