public SystemConfigurationObject UpdateSystemConfigurations(SystemConfigurationObject model) { /*here to check the minimum values have been put in*/ var dbObj = _dataRepository.Query(x => x.SettingId == 1).First(); dbObj.AnalyticsTrackingRef = model.AnalyticsTrackingRef; dbObj.CouncilName = model.CouncilName; dbObj.CouncilUri = model.CouncilUri; dbObj.CouncilUrl = model.CouncilUrl; dbObj.CouncilSpatialUri = model.CouncilSpatialUri; dbObj.MapCentreLatitude = model.MapCentreLatitude; dbObj.MapCentreLongitude = model.MapCentreLongitude; dbObj.MapDefaultZoom = model.MapDefaultZoom; dbObj.SendEmailForFeedback = model.SendEmailForFeedback; dbObj.SmtpServer = model.SmtpServer; dbObj.SmtpUsername = model.SmtpUsername; dbObj.SmtpPassword = model.SmtpPassword; _dataRepository.SaveChanges(); if (_cacheProvider != null) { _cacheProvider.Set("GetSystemConfigurations", dbObj); } return(dbObj); }
public void UpdateSystemConfiguration_when_cacheprovider_is_not_null_sets_updatedsystemconfiguration_setting_id_1_in_cache() { //arrange var sysconfig = new SystemConfigurationObject() { SettingId = 1 }; _repository.Add(sysconfig); var sysConfigToUpdate = new SystemConfigurationObject() { SettingId = 1, CouncilName = "test" }; var mut = new SystemConfigurationService(_repository, _fakecacheprovider); //act mut.UpdateSystemConfigurations(sysConfigToUpdate); SystemConfigurationObject resultObj; _fakecacheprovider.Get("GetSystemConfigurations", out resultObj); //assert Assert.AreEqual(sysconfig, resultObj); //cleanup _repository.Delete(sysconfig); _fakecacheprovider.Clear("GetSystemConfigurations"); }
public void GetSystemConfiguration_returns_systemconfiguration_setting_id_1() { //arrange var sysconfig = new SystemConfigurationObject() { SettingId = 1 }; _repository.Add(sysconfig); var mut = new SystemConfigurationService(_repository, _fakecacheprovider); //act var result = mut.GetSystemConfigurations(); //assert Assert.AreEqual(sysconfig, result); //cleanup _repository.Delete(sysconfig); }
public void GetSystemConfiguration_when_cache_provider_is_not_null_and_cache_value_is_not_null_return_cache_value() { //arrange var sysconfig = new SystemConfigurationObject() { SettingId = 2 }; _fakecacheprovider.Set("GetSystemConfigurations", sysconfig); var mut = new SystemConfigurationService(_repository, _fakecacheprovider); //act var result = mut.GetSystemConfigurations(); //assert Assert.AreEqual(sysconfig, result); //cleanup _fakecacheprovider.Clear("GetSystemConfigurations"); }
public SystemConfigurationObject GetSystemConfigurations() { SystemConfigurationObject cachedValue = null; if (_cacheProvider != null) { _cacheProvider.Get("GetSystemConfigurations", out cachedValue); } if (cachedValue != null) { return(cachedValue); } cachedValue = _dataRepository.Query(x => x.SettingId == 1).First(); _cacheProvider.Set("GetSystemConfigurations", cachedValue, 1); return(cachedValue); }
public void GetSystemConfiguration_when_no_result_in_cache_sets_systemconfiguration_setting_id_1_in_cache() { //arrange var sysconfig = new SystemConfigurationObject() { SettingId = 1 }; _repository.Add(sysconfig); var mut = new SystemConfigurationService(_repository, _fakecacheprovider); //act mut.GetSystemConfigurations(); SystemConfigurationObject resultObj; _fakecacheprovider.Get("GetSystemConfigurations", out resultObj); //assert Assert.AreEqual(sysconfig, resultObj); //cleanup _repository.Delete(sysconfig); _fakecacheprovider.Clear("GetSystemConfigurations"); }
public void UpdateSystemConfiguration_updates_defaultzoom_reference_in_repository() { //arrange var sysconfig = new SystemConfigurationObject() { SettingId = 1 }; _repository.Add(sysconfig); var sysConfigToUpdate = new SystemConfigurationObject() { SettingId = 1, MapDefaultZoom = "12" }; var mut = new SystemConfigurationService(_repository, _fakecacheprovider); //act var result = mut.UpdateSystemConfigurations(sysConfigToUpdate); //assert Assert.AreEqual("12", result.MapDefaultZoom); //cleanup _repository.Delete(sysconfig); _fakecacheprovider.Clear("GetSystemConfigurations"); }
public void UpdateSystemConfiguration_updates_CouncilSpatialUri_reference_in_repository() { //arrange var sysconfig = new SystemConfigurationObject() { SettingId = 1 }; _repository.Add(sysconfig); var sysConfigToUpdate = new SystemConfigurationObject() { SettingId = 1, CouncilSpatialUri = "spatial" }; var mut = new SystemConfigurationService(_repository, _fakecacheprovider); //act var result = mut.UpdateSystemConfigurations(sysConfigToUpdate); //assert Assert.AreEqual("spatial", result.CouncilSpatialUri); //cleanup _repository.Delete(sysconfig); _fakecacheprovider.Clear("GetSystemConfigurations"); }
public void UpdateSystemConfiguration_updates_analytics_tracking_reference_in_repository() { //arrange var sysconfig = new SystemConfigurationObject() { SettingId = 1 }; _repository.Add(sysconfig); var sysConfigToUpdate = new SystemConfigurationObject() { SettingId = 1, AnalyticsTrackingRef = "analytics" }; var mut = new SystemConfigurationService(_repository, _fakecacheprovider); //act var result = mut.UpdateSystemConfigurations(sysConfigToUpdate); //assert Assert.AreEqual("analytics", result.AnalyticsTrackingRef); //cleanup _repository.Delete(sysconfig); _fakecacheprovider.Clear("GetSystemConfigurations"); }