Nettiers.AdventureWorks.UnitTests.ProductVendorTest.CreateMockInstance_Generated C# (CSharp) Method

CreateMockInstance_Generated() static public method

Returns a Typed ProductVendor Entity with mock values.
static public CreateMockInstance_Generated ( TransactionManager tm ) : ProductVendor
tm TransactionManager
return Nettiers.AdventureWorks.Entities.ProductVendor
		static public ProductVendor CreateMockInstance_Generated(TransactionManager tm)
		{		
			ProductVendor mock = new ProductVendor();
						
			mock.AverageLeadTime = TestUtility.Instance.RandomNumber();
			mock.StandardPrice = TestUtility.Instance.RandomShort();
			mock.LastReceiptCost = TestUtility.Instance.RandomShort();
			mock.LastReceiptDate = TestUtility.Instance.RandomDateTime();
			mock.MinOrderQty = TestUtility.Instance.RandomNumber();
			mock.MaxOrderQty = TestUtility.Instance.RandomNumber();
			mock.OnOrderQty = TestUtility.Instance.RandomNumber();
			mock.ModifiedDate = TestUtility.Instance.RandomDateTime();
			
			//OneToOneRelationship
			Product mockProductByProductId = ProductTest.CreateMockInstance(tm);
			DataRepository.ProductProvider.Insert(tm, mockProductByProductId);
			mock.ProductId = mockProductByProductId.ProductId;
			//OneToOneRelationship
			UnitMeasure mockUnitMeasureByUnitMeasureCode = UnitMeasureTest.CreateMockInstance(tm);
			DataRepository.UnitMeasureProvider.Insert(tm, mockUnitMeasureByUnitMeasureCode);
			mock.UnitMeasureCode = mockUnitMeasureByUnitMeasureCode.UnitMeasureCode;
			//OneToOneRelationship
			Vendor mockVendorByVendorId = VendorTest.CreateMockInstance(tm);
			DataRepository.VendorProvider.Insert(tm, mockVendorByVendorId);
			mock.VendorId = mockVendorByVendorId.VendorId;
		
			// create a temporary collection and add the item to it
			TList<ProductVendor> tempMockCollection = new TList<ProductVendor>();
			tempMockCollection.Add(mock);
			tempMockCollection.Remove(mock);
			
		
		   return (ProductVendor)mock;
		}
		

Usage Example

        ///<summary>
        ///  Returns a Typed ProductVendor Entity with mock values.
        ///</summary>
        static public ProductVendor CreateMockInstance(TransactionManager tm)
        {
            // get the default mock instance
            ProductVendor mock = ProductVendorTest.CreateMockInstance_Generated(tm);

            // make any alterations necessary
            // (i.e. for DB check constraints, special test cases, etc.)
            SetSpecialTestData(mock);

            // return the modified object
            return(mock);
        }