public void NextAccountNumber_saves_next_account_number()
        {
            var setting = new Setting(1) { Value = "1" };
            _settingRepository.ExpectGet(s => s["NextAccountNumber"]).Returns(setting);
            _settingRepository.ExpectGet(s => s["AccountNumberPrefix"]).Returns(new Setting(2) { Value = "AC" });
            _settingRepository.ExpectGet(s => s["AccountNumberFormat"]).Returns(new Setting(3) { Value = "0000" });

            _service.NextAccountNumber();

            _settingRepository.Verify(s => s.Commit(It.Is<Setting>(v => v.Value == "2")));
        }
示例#2
0
        public bool Commit(Setting entity)
        {
            using (var db = DbFactory.GetDataContext()) {
                var setting = new SystemSetting();
                if (entity.Id != null) {
                    setting = db.SystemSettings.First(x => x.SystemSettingId == entity.Id.Value);
                    if (setting == null)
                        throw new UnknownEntityException("Could not find System Setting with Id " + entity.Id.Value);
                }

                CopySettingEntityToSystemSetting(entity, setting);
                if (entity.Id == null)
                    db.SystemSettings.InsertOnSubmit(setting);

                db.SubmitChanges();
                entity.Inserted(setting.SystemSettingId);

                return true;
            }
        }
示例#3
0
 private void CopySettingEntityToSystemSetting(Setting setting, SystemSetting set)
 {
     set.KeyName = setting.Name;
      set.KeyValue = setting.Value;
      set.IsSystem = setting.IsSystem;
 }
        public void NextInvoiceRunNumber_saves_next_invoice_run_number()
        {
            var setting = new Setting(1) { Value = "1" };
            _settingRepository.ExpectGet(s => s["NextInvoiceRunNumber"]).Returns(setting);

            _service.NextInvoiceRunNumber();

            _settingRepository.Verify(s => s.Commit(It.Is<Setting>(v => v.Value == "2")));
        }