public void DateTimeActivityViewModel_UpdateHelp_ShouldCallToHelpViewMode() { //------------Setup for test-------------------------- var expected = string.Empty; const string TimeModifierAmountDisplay = "TimeModifierAmountDisplay"; var prop = new Mock <ModelProperty>(); var properties = new Dictionary <string, Mock <ModelProperty> >(); var propertyCollection = new Mock <ModelPropertyCollection>(); var mockModel = new Mock <ModelItem>(); prop.Setup(p => p.SetValue(expected)).Verifiable(); properties.Add(TimeModifierAmountDisplay, prop); propertyCollection.Protected().Setup <ModelProperty>("Find", TimeModifierAmountDisplay, true).Returns(prop.Object); mockModel.Setup(s => s.Properties).Returns(propertyCollection.Object); var mockMainViewModel = new Mock <IShellViewModel>(); var mockHelpViewModel = new Mock <IHelpWindowViewModel>(); mockHelpViewModel.Setup(model => model.UpdateHelpText(It.IsAny <string>())).Verifiable(); mockMainViewModel.Setup(model => model.HelpViewModel).Returns(mockHelpViewModel.Object); CustomContainer.Register(mockMainViewModel.Object); var viewModel = new DateTimeDesignerViewModel(mockModel.Object) { SelectedTimeModifierType = expected }; //------------Execute Test--------------------------- viewModel.UpdateHelpDescriptor("help"); //------------Assert Results------------------------- mockHelpViewModel.Verify(model => model.UpdateHelpText(It.IsAny <string>()), Times.Once()); }
public void DateTimeActivityViewModel_SelectedTimeModifierTypeChange_SelectedTimeModifierTypeSetToABlankString_TimeModifierAmountDisplayCleared() { //init var expected = string.Empty; const string TimeModifierAmountDisplay = "TimeModifierAmountDisplay"; var prop = new Mock <ModelProperty>(); var properties = new Dictionary <string, Mock <ModelProperty> >(); var propertyCollection = new Mock <ModelPropertyCollection>(); var mockModel = new Mock <ModelItem>(); prop.Setup(p => p.SetValue(expected)).Verifiable(); properties.Add(TimeModifierAmountDisplay, prop); propertyCollection.Protected().Setup <ModelProperty>("Find", TimeModifierAmountDisplay, true).Returns(prop.Object); mockModel.Setup(s => s.Properties).Returns(propertyCollection.Object); //exe var viewModel = new DateTimeDesignerViewModel(mockModel.Object) { SelectedTimeModifierType = expected }; viewModel.Validate(); //assert prop.Verify(c => c.SetValue(expected), Times.Once(), "Find Records ViewModel does not clear the match data property of the model item when it's no longer needed"); Assert.IsTrue(viewModel.HasLargeView); }