示例#1
0
        public async Task InterestingViewModel_Event_Closed()
        {
            ViewModelManager.ClearAll();

            var interestingViewModel = new InterestingViewModel();
            var interestedViewModel  = new InterestedViewModel();

            await interestingViewModel.CloseViewModelAsync(null);

            Assert.AreEqual(1, interestedViewModel.ViewModelEvents.Count);
            Assert.AreEqual(ViewModelEvent.Closed, interestedViewModel.ViewModelEvents[0]);

            await interestingViewModel.CloseViewModelAsync(false);

            await interestedViewModel.CloseViewModelAsync(false);
        }
示例#2
0
        public async Task InterestedViewModelAutomaticallyBeingRemovedWhenClosed()
        {
            ViewModelManager.ClearAll();

            var viewModel = new ManagedViewModel(typeof(InterestingViewModel));

            var interestingViewModel = new InterestingViewModel();
            var interestedViewModel  = new InterestedViewModel();

            viewModel.AddViewModelInstance(interestingViewModel);
            viewModel.AddInterestedViewModel(interestedViewModel);

            interestingViewModel.InterestingValue = "new value";
            Assert.AreEqual("new value", interestedViewModel.InterestedValue);

            await interestedViewModel.CloseViewModelAsync(null);

            interestingViewModel.InterestingValue = "new value which has changed";
            Assert.AreNotEqual("new value which has changed", interestedViewModel.InterestedValue);
            Assert.AreEqual("new value", interestedViewModel.InterestedValue);

            await interestingViewModel.CloseViewModelAsync(false);

            await interestedViewModel.CloseViewModelAsync(false);
        }
示例#3
0
        public async Task InterestingViewModel_Event_SavingAndSaved()
        {
            ViewModelManager.ClearAll();

            var interestingViewModel = new InterestingViewModel();
            var interestedViewModel  = new InterestedViewModel();

            await interestingViewModel.SaveViewModelAsync();

            Assert.AreEqual(2, interestedViewModel.ViewModelEvents.Count);
            Assert.AreEqual(ViewModelEvent.Saving, interestedViewModel.ViewModelEvents[0]);
            Assert.AreEqual(ViewModelEvent.Saved, interestedViewModel.ViewModelEvents[1]);

            await interestingViewModel.CloseViewModelAsync(false);

            await interestedViewModel.CloseViewModelAsync(false);
        }
示例#4
0
        public async Task InterestingViewModelPropertyChanged()
        {
            ViewModelManager.ClearAll();

            var viewModel = new ManagedViewModel(typeof(InterestingViewModel));

            var interestingViewModel = new InterestingViewModel();
            var interestedViewModel  = new InterestedViewModel();

            viewModel.AddViewModelInstance(interestingViewModel);
            viewModel.AddInterestedViewModel(interestedViewModel);

            interestingViewModel.InterestingValue = "new value";
            Assert.AreEqual("new value", interestedViewModel.InterestedValue);

            await interestingViewModel.CloseViewModelAsync(false);

            await interestedViewModel.CloseViewModelAsync(false);
        }
示例#5
0
        public async Task InterestingViewModelCommandExecutedWithCommandParameter()
        {
            ViewModelManager.ClearAll();

            var viewModel = new ManagedViewModel(typeof(InterestingViewModel));

            var interestingViewModel = new InterestingViewModel();
            var interestedViewModel  = new InterestedViewModel();

            viewModel.AddViewModelInstance(interestingViewModel);
            viewModel.AddInterestedViewModel(interestedViewModel);

            interestingViewModel.TestCommand.Execute("parameter");
            Assert.AreEqual(true, interestedViewModel.CommandHasBeenExecuted);
            Assert.AreEqual(true, interestedViewModel.CommandHasBeenExecutedWithParameter);

            await interestingViewModel.CloseViewModelAsync(false);

            await interestedViewModel.CloseViewModelAsync(false);
        }
        public async Task InterestingViewModel_Event_Closed()
        {
            ViewModelManager.ClearAll();

            var interestingViewModel = new InterestingViewModel();
            var interestedViewModel = new InterestedViewModel();

            await interestingViewModel.CloseViewModelAsync(null);

            Assert.AreEqual(1, interestedViewModel.ViewModelEvents.Count);
            Assert.AreEqual(ViewModelEvent.Closed, interestedViewModel.ViewModelEvents[0]);

            await interestingViewModel.CloseViewModelAsync(false);
            await interestedViewModel.CloseViewModelAsync(false);
        }
        public async Task InterestingViewModel_Event_SavingAndSaved()
        {
            ViewModelManager.ClearAll();

            var interestingViewModel = new InterestingViewModel();
            var interestedViewModel = new InterestedViewModel();

            await interestingViewModel.SaveViewModelAsync();

            Assert.AreEqual(2, interestedViewModel.ViewModelEvents.Count);
            Assert.AreEqual(ViewModelEvent.Saving, interestedViewModel.ViewModelEvents[0]);
            Assert.AreEqual(ViewModelEvent.Saved, interestedViewModel.ViewModelEvents[1]);

            await interestingViewModel.CloseViewModelAsync(false);
            await interestedViewModel.CloseViewModelAsync(false);
        }
        public async Task InterestedViewModelAutomaticallyBeingRemovedWhenClosed()
        {
            ViewModelManager.ClearAll();

            var viewModel = new ManagedViewModel(typeof (InterestingViewModel));

            var interestingViewModel = new InterestingViewModel();
            var interestedViewModel = new InterestedViewModel();

            viewModel.AddViewModelInstance(interestingViewModel);
            viewModel.AddInterestedViewModel(interestedViewModel);

            interestingViewModel.InterestingValue = "new value";
            Assert.AreEqual("new value", interestedViewModel.InterestedValue);

            await interestedViewModel.CloseViewModelAsync(null);

            interestingViewModel.InterestingValue = "new value which has changed";
            Assert.AreNotEqual("new value which has changed", interestedViewModel.InterestedValue);
            Assert.AreEqual("new value", interestedViewModel.InterestedValue);

            await interestingViewModel.CloseViewModelAsync(false);
            await interestedViewModel.CloseViewModelAsync(false);
        }
        public async Task InterestingViewModelCommandExecutedWithCommandParameter()
        {
            ViewModelManager.ClearAll();

            var viewModel = new ManagedViewModel(typeof (InterestingViewModel));

            var interestingViewModel = new InterestingViewModel();
            var interestedViewModel = new InterestedViewModel();

            viewModel.AddViewModelInstance(interestingViewModel);
            viewModel.AddInterestedViewModel(interestedViewModel);

            interestingViewModel.TestCommand.Execute("parameter");
            Assert.AreEqual(true, interestedViewModel.CommandHasBeenExecuted);
            Assert.AreEqual(true, interestedViewModel.CommandHasBeenExecutedWithParameter);

            await interestingViewModel.CloseViewModelAsync(false);
            await interestedViewModel.CloseViewModelAsync(false);
        }
        public async Task InterestingViewModelPropertyChanged()
        {
            ViewModelManager.ClearAll();

            var viewModel = new ManagedViewModel(typeof (InterestingViewModel));

            var interestingViewModel = new InterestingViewModel();
            var interestedViewModel = new InterestedViewModel();

            viewModel.AddViewModelInstance(interestingViewModel);
            viewModel.AddInterestedViewModel(interestedViewModel);

            interestingViewModel.InterestingValue = "new value";
            Assert.AreEqual("new value", interestedViewModel.InterestedValue);

            await interestingViewModel.CloseViewModelAsync(false);
            await interestedViewModel.CloseViewModelAsync(false);
        }