///<summary> /// Returns a Typed AlphabeticalListOfProducts Entity with mock values. ///</summary> public static AlphabeticalListOfProducts CreateMockInstance() { AlphabeticalListOfProducts mock = new AlphabeticalListOfProducts(); mock.ProductId = TestUtility.Instance.RandomNumber(); mock.ProductName = TestUtility.Instance.RandomString(19, false);; mock.SupplierId = TestUtility.Instance.RandomNumber(); mock.CategoryId = TestUtility.Instance.RandomNumber(); mock.QuantityPerUnit = TestUtility.Instance.RandomString(9, false);; mock.UnitPrice = TestUtility.Instance.RandomShort(); mock.UnitsInStock = TestUtility.Instance.RandomShort(); mock.UnitsOnOrder = TestUtility.Instance.RandomShort(); mock.ReorderLevel = TestUtility.Instance.RandomShort(); mock.Discontinued = TestUtility.Instance.RandomBoolean(); mock.CategoryName = TestUtility.Instance.RandomString(6, false);; return (AlphabeticalListOfProducts)mock; }
/// <summary> /// Deserialize the mock AlphabeticalListOfProducts entity from a temporary file. /// </summary> private void Step_7_DeserializeEntity_Generated() { string fileName = "temp_AlphabeticalListOfProducts.xml"; XmlSerializer mySerializer = new XmlSerializer(typeof(AlphabeticalListOfProducts)); System.IO.FileStream myFileStream = new System.IO.FileStream(fileName, System.IO.FileMode.Open); mock = (AlphabeticalListOfProducts) mySerializer.Deserialize(myFileStream); myFileStream.Close(); System.IO.File.Delete(fileName); System.Console.WriteLine("mock correctly deserialized from a temporary file."); }
/// <summary> /// Gets the property value by name. /// </summary> /// <param name="entity">The entity.</param> /// <param name="propertyName">Name of the property.</param> /// <returns></returns> public static object GetPropertyValueByName(AlphabeticalListOfProducts entity, string propertyName) { switch (propertyName) { case "ProductId": return entity.ProductId; case "ProductName": return entity.ProductName; case "SupplierId": return entity.SupplierId; case "CategoryId": return entity.CategoryId; case "QuantityPerUnit": return entity.QuantityPerUnit; case "UnitPrice": return entity.UnitPrice; case "UnitsInStock": return entity.UnitsInStock; case "UnitsOnOrder": return entity.UnitsOnOrder; case "ReorderLevel": return entity.ReorderLevel; case "Discontinued": return entity.Discontinued; case "CategoryName": return entity.CategoryName; } return null; }
///<summary> /// Returns a Typed AlphabeticalListOfProductsBase Entity ///</summary> public virtual AlphabeticalListOfProductsBase Copy() { //shallow copy entity AlphabeticalListOfProducts copy = new AlphabeticalListOfProducts(); copy.ProductId = this.ProductId; copy.ProductName = this.ProductName; copy.SupplierId = this.SupplierId; copy.CategoryId = this.CategoryId; copy.QuantityPerUnit = this.QuantityPerUnit; copy.UnitPrice = this.UnitPrice; copy.UnitsInStock = this.UnitsInStock; copy.UnitsOnOrder = this.UnitsOnOrder; copy.ReorderLevel = this.ReorderLevel; copy.Discontinued = this.Discontinued; copy.CategoryName = this.CategoryName; copy.AcceptChanges(); return (AlphabeticalListOfProducts)copy; }
///<summary> /// A simple factory method to create a new <see cref="AlphabeticalListOfProducts"/> instance. ///</summary> ///<param name="_productId"></param> ///<param name="_productName"></param> ///<param name="_supplierId"></param> ///<param name="_categoryId"></param> ///<param name="_quantityPerUnit"></param> ///<param name="_unitPrice"></param> ///<param name="_unitsInStock"></param> ///<param name="_unitsOnOrder"></param> ///<param name="_reorderLevel"></param> ///<param name="_discontinued"></param> ///<param name="_categoryName"></param> public static AlphabeticalListOfProducts CreateAlphabeticalListOfProducts(System.Int32 _productId, System.String _productName, System.Int32? _supplierId, System.Int32? _categoryId, System.String _quantityPerUnit, System.Decimal? _unitPrice, System.Int16? _unitsInStock, System.Int16? _unitsOnOrder, System.Int16? _reorderLevel, System.Boolean _discontinued, System.String _categoryName) { AlphabeticalListOfProducts newAlphabeticalListOfProducts = new AlphabeticalListOfProducts(); newAlphabeticalListOfProducts.ProductId = _productId; newAlphabeticalListOfProducts.ProductName = _productName; newAlphabeticalListOfProducts.SupplierId = _supplierId; newAlphabeticalListOfProducts.CategoryId = _categoryId; newAlphabeticalListOfProducts.QuantityPerUnit = _quantityPerUnit; newAlphabeticalListOfProducts.UnitPrice = _unitPrice; newAlphabeticalListOfProducts.UnitsInStock = _unitsInStock; newAlphabeticalListOfProducts.UnitsOnOrder = _unitsOnOrder; newAlphabeticalListOfProducts.ReorderLevel = _reorderLevel; newAlphabeticalListOfProducts.Discontinued = _discontinued; newAlphabeticalListOfProducts.CategoryName = _categoryName; return newAlphabeticalListOfProducts; }