// // You can use the following additional attributes as you write your tests: // // Use ClassInitialize to run code before running the first test in the class // [ClassInitialize()] // public static void MyClassInitialize(TestContext testContext) { } // // Use ClassCleanup to run code after all tests in a class have run // [ClassCleanup()] // public static void MyClassCleanup() { } // // Use TestInitialize to run code before running each test // [TestInitialize()] // public void MyTestInitialize() { } // // Use TestCleanup to run code after each test has run // [TestCleanup()] // public void MyTestCleanup() { } // #endregion public WebFactorOrigin GetFactorOrigin() { if (_factorOrigin.IsNull()) { _factorOrigin = FactorManagerTest.GetOneFactorOrigin(GetContext()); } return(_factorOrigin); }
/// <summary> /// Load data into the WebFactorOrigin instance. /// </summary> /// <param name="factorOrigin">The factor origin instance.</param> /// <param name='dataReader'>An open data reader.</param> public static void LoadData(this WebFactorOrigin factorOrigin, DataReader dataReader) { factorOrigin.Definition = dataReader.GetString(FactorOriginData.DEFINITION); factorOrigin.Id = dataReader.GetInt32(FactorOriginData.ID); factorOrigin.Name = dataReader.GetString(FactorOriginData.NAME); factorOrigin.SortOrder = dataReader.GetInt32(FactorOriginData.SORT_ORDER); }
/// <summary> /// Convert a WebFactorOrigin instance into /// an IFactorOrigin instance. /// </summary> /// <param name="userContext"> /// Information about the user that makes this method call. /// </param> /// <param name="webFactorOrigin">A WebFactorOrigin instance.</param> /// <returns>An IFactorOrigin instance.</returns> private IFactorOrigin GetFactorOrigin(IUserContext userContext, WebFactorOrigin webFactorOrigin) { IFactorOrigin factorOrigin; factorOrigin = new FactorOrigin(); factorOrigin.DataContext = GetDataContext(userContext); factorOrigin.Definition = webFactorOrigin.Definition; factorOrigin.Id = webFactorOrigin.Id; factorOrigin.Name = webFactorOrigin.Name; factorOrigin.SortOrder = webFactorOrigin.SortOrder; return(factorOrigin); }
/// <summary> /// Get all factor origins. /// </summary> /// <param name="context">Web service request context.</param> /// <returns>All factor origins.</returns> public static List <WebFactorOrigin> GetFactorOrigins(WebServiceContext context) { List <WebFactorOrigin> factorOrigins; String cacheKey; WebFactorOrigin factorOrigin; // Get cached information. factorOrigins = null; cacheKey = Settings.Default.FactorOriginCacheKey; if (!context.IsInTransaction()) { factorOrigins = (List <WebFactorOrigin>)context.GetCachedObject(cacheKey); } if (factorOrigins.IsNull()) { // Get information from database. factorOrigins = new List <WebFactorOrigin>(); using (DataReader dataReader = context.GetTaxonAttributeDatabase().GetFactorOrigins()) { while (dataReader.Read()) { factorOrigin = new WebFactorOrigin(); factorOrigin.LoadData(dataReader); factorOrigins.Add(factorOrigin); } } if (!context.IsInTransaction()) { // Add information to cache. context.AddCachedObject(cacheKey, factorOrigins, DateTime.Now + new TimeSpan(12, 0, 0), CacheItemPriority.AboveNormal); } } return(factorOrigins); }
public WebFactorOriginTest() { _factorOrigin = null; }