コード例 #1
0
        public void SaveCommandEndsEditsAndSavesSettings()
        {
            var vm = CreateVm();

            var childViewModel = new TestViewmodel();

            vm.HasUnsavedChanges = true;;
            vm.SaveCommand.Execute(null);

            _appSettings.Verify(m => m.Save(), Times.Once);
            _messageBus.Verify(m => m.Publish(It.Is <EditEndMessage>(msg => msg == EditEndMessage.Accepted), It.IsAny <string>()));
            Assert.IsFalse(vm.HasUnsavedChanges);
        }
コード例 #2
0
        public void SelectProfileEndsEdits()
        {
            string profile1 = "profile 1";
            string profile2 = "profile 2";

            var vm             = CreateVm();
            var childViewModel = new TestViewmodel();

            vm.SelectedViewModel = childViewModel;
            childViewModel.BeginEdit();
            _appSettings.SetupGet(m => m.Profiles).Returns(new List <string> {
                profile1, profile2
            });

            vm.SelectedProfileName = profile2;

            Assert.IsFalse(vm.IsEditing);
        }
コード例 #3
0
        public void SelectProfileCommandExecuted_PublishesEndsEditMessage()
        {
            var profile1 = new UserProfile {
                Name = "profile 1"
            };
            var profile2 = new UserProfile {
                Name = "profile 2"
            };

            var vm             = CreateVm();
            var childViewModel = new TestViewmodel();

            vm.SelectedViewModel = childViewModel;
            childViewModel.BeginEdit();
            _appSettings.SetupGet(m => m.Profiles).Returns(new List <UserProfile> {
                profile1, profile2
            });

            vm.SelectedProfileName = profile2.Name;

            Assert.False(vm.IsEditing);
        }