public void OnViewModelWithoutChanges_ShouldNotSaveChanges()
        {
            MasterDetailViewModel viewModel = CreateMasterDetailViewModel();

            viewModel.Save();
            _commander.Verify(c => c.SaveChanges(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <IEnumerable <KeyValueChange> >()), Times.Never);
        }
        public void OnViewModelWithChange_ShouldClearChanges()
        {
            KeyValueChange        change    = RandomKeyValueChange();
            MasterDetailViewModel viewModel = CreateMasterDetailViewModel();

            viewModel.KeyValueChanged(change);
            viewModel.Save();
            viewModel.Changes.Should().BeEmpty();
        }
        public void OnViewModelWithChange_ShouldSaveChangeOnCommander()
        {
            KeyValueChange        change    = RandomKeyValueChange();
            MasterDetailViewModel viewModel = CreateMasterDetailViewModel();

            viewModel.KeyValueChanged(change);
            viewModel.Save();
            _commander.Verify(c => c.SaveChanges(_randomModule, _randomController, It.IsAny <IEnumerable <KeyValueChange> >()));
        }
        public void OnCommanderThatThrows_ShouldExposeErrorMessage()
        {
            string randomError = CreateRandom.String();

            _commander.Setup(c => c.SaveChanges(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <IEnumerable <KeyValueChange> >()))
            .Throws(new Exception(randomError));
            MasterDetailViewModel viewModel = CreateMasterDetailViewModel();

            viewModel.KeyValueChanged(RandomKeyValueChange());
            viewModel.Save();
            _states.Verify(s => s.ChangeToErrorState(It.Is <string>(e => e.Contains(randomError))));
        }