Пример #1
0
        public void WhenVmIsInitializedPropertyIsInitializedShouldChanged()
        {
            var testViewModel = new TestViewModelBase();

            testViewModel.IsInitialized.ShouldBeFalse();
            ViewModelProvider.InitializeViewModel(testViewModel, null);
            testViewModel.IsInitialized.ShouldBeTrue();
        }
        public void InitializedEventShouldBeInvokedAfterViewModelWasInitialized()
        {
            var testViewModel = new TestViewModelBase();

            testViewModel.IsInitialized.ShouldBeFalse();
            bool   isInvoked    = false;
            Action invokeAction = () => isInvoked = true;

            testViewModel.Initialized += (sender, args) => invokeAction();
            isInvoked.ShouldBeFalse();

            ViewModelProvider.InitializeViewModel(testViewModel, null);
            testViewModel.IsInitialized.ShouldBeTrue();
            isInvoked.ShouldBeTrue();
        }
        public CompositeViewModel(IMessagePresenter messagePresenter)
        {
            Should.NotBeNull(messagePresenter, "messagePresenter");
            _messagePresenter = messagePresenter;

            _firstNestedViewModel             = GetViewModel <CompositeNestedViewModel>();
            _firstNestedViewModel.DisplayName = "First nested view model";

            _secondNestedViewModel = GetViewModel(container => new CompositeNestedViewModel {
                DisplayName = "Second nested view model"
            });

            _thirdNestedViewModel = new CompositeNestedViewModel {
                DisplayName = "Third nested view model"
            };
            ViewModelProvider.InitializeViewModel(_thirdNestedViewModel, DataContext.Empty);
        }