public void ModelIsChanged_WhenViewModelIsClosedAndMessageResultIsNo_ThenOnChangesCancelingIsCalled()
        {
            string initialValue       = string.Empty;
            var    simpleModel        = new SimpleEditableModel(initialValue, 20);
            var    stubMessageService = new FakeMessageService();

            stubMessageService.SetMessageResult(MessageResult.No);
            RegisterInstance <IMessageService>(stubMessageService);

            var rootObject            = CreateRootObject();
            var screenObjectViewModel = new TestEditableScreenSimpleObjectViewModel(stubMessageService, simpleModel);

            rootObject.ActivateItem(screenObjectViewModel);
            simpleModel.Name = DataGenerator.ValidName;
            screenObjectViewModel.CloseCommand.Execute(null);

            var wasCalled = screenObjectViewModel.WasCancelingChangesCalled;

            wasCalled.Should().BeTrue();
        }
        public void ModelIsChanged_WhenViewModelIsClosedAndMessageResultIsYes_ModelIsSaved()
        {
            var simpleModel        = new SimpleEditableModel();
            var stubMessageService = new FakeMessageService();

            stubMessageService.SetMessageResult(MessageResult.Yes);

            var rootObject            = CreateRootObject();
            var screenObjectViewModel = new TestEditableScreenSimpleObjectViewModel(stubMessageService, simpleModel);

            rootObject.ActivateItem(screenObjectViewModel);
            const string expectedValue = DataGenerator.ValidName;

            simpleModel.Name = expectedValue;
            screenObjectViewModel.CloseCommand.Execute(null);

            var isDirty = simpleModel.IsDirty;

            isDirty.Should().BeFalse();
            var actualValue = simpleModel.Name;

            actualValue.Should().Be(expectedValue);
        }
        public void ModelIsChanged_WhenViewModelIsClosedAndMessageResultIsCancel_ModelIsSaved()
        {
            string       initialValue       = string.Empty;
            const string newValue           = DataGenerator.ValidName;
            var          simpleModel        = new SimpleEditableModel(initialValue, 20);
            var          stubMessageService = new FakeMessageService();

            stubMessageService.SetMessageResult(MessageResult.Cancel);

            var rootObject            = CreateRootObject();
            var screenObjectViewModel = new TestEditableScreenSimpleObjectViewModel(stubMessageService, simpleModel);

            rootObject.ActivateItem(screenObjectViewModel);
            simpleModel.Name = newValue;
            screenObjectViewModel.CloseCommand.Execute(null);

            var isDirty = simpleModel.IsDirty;

            isDirty.Should().BeTrue();
            var actualValue = simpleModel.Name;

            actualValue.Should().Be(DataGenerator.ValidName);
        }