예제 #1
0
		public void TestAcceptance_GenerateFirstNumber_SeedZero()
		{
			//---------------Clean Up --------------------------
			//Create an entry in the number generator table for entry type to seed.
			BOSequenceNumber.LoadNumberGenClassDef();
			const string numberType = "tmp";
			SetNumberGeneratorSeedZero(numberType);
			//---------------Set up test pack-------------------
			//Create an instance of the number for a specific type of number (e.g. Invoice number)
			INumberGenerator numGen = new NumberGenerator("tmp");

			//---------------Execute Test ----------------------
			//get the next number for invoice number
			long nextNum = numGen.NextNumber();

			//---------------Test Result -----------------------
			//test nextnumber should be one.
			Assert.AreEqual(1, nextNum);
			//---------------Tear Down -------------------------  
		}
예제 #2
0
		///<summary>
		/// Executes any custom code required by the business object before it is persisted to the database.
		/// This has the additionl capability of creating or updating other business objects and adding these
		/// to the transaction committer.
		/// <remarks> Recursive call to UpdateObjectBeforePersisting will not be done i.e. it is the bo developers responsibility to implement</remarks>
		///</summary>
		///<param name="transactionCommitter">the transaction committer that is executing the transaction</param>
		protected internal override void UpdateObjectBeforePersisting(ITransactionCommitter transactionCommitter)
		{
			base.UpdateObjectBeforePersisting(transactionCommitter);
			INumberGenerator numGen = new NumberGenerator("GeneratedNumber");
			this.GeneratedNumber = numGen.NextNumber().ToString();
			numGen.AddToTransaction(transactionCommitter);
		}
예제 #3
0
		public void TestDifferentTableNameGetSecondNumber_FromSeperateNumberGeneratorInstance_AfterUpdate()
		{
			//---------------Clean Up --------------------------
			BOSequenceNumber.LoadNumberGenClassDef("another_number_generator");
			NumberGenerator numGen = new NumberGenerator("tmp", "another_number_generator");
			numGen.SetSequenceNumber(0);
			//---------------Set up test pack-------------------
			//---------------Execute Test ----------------------
			numGen.NextNumber();
			numGen.Save();
			numGen = new NumberGenerator("tmp", "another_number_generator");
			long nextNum = numGen.NextNumber();
			//---------------Test Result -----------------------
			Assert.AreEqual(2, nextNum);

		}
예제 #4
0
		private static void SetNumberGeneratorSeedZero(string numberType)
		{
			INumberGenerator numGen = new NumberGenerator(numberType);
			numGen.SetSequenceNumber(0);
		}
예제 #5
0
		public void TestSetSequenceNumber()
		{
			//---------------Set up test pack-------------------
			BOSequenceNumber.LoadNumberGenClassDef();
			NumberGenerator numGen = new NumberGenerator("tmp");
			numGen.NextNumber();
			numGen.Save();
			Assert.GreaterOrEqual( numGen.NextNumber(),1);
			//---------------Execute Test ----------------------
			numGen.SetSequenceNumber(0);
			//---------------Test Result -----------------------
			numGen = new NumberGenerator("tmp");
			Assert.AreEqual(1, numGen.NextNumber());
			//---------------Tear Down -------------------------          
		}
예제 #6
0
		public void TestDifferentTableName()
		{
			//---------------Set up test pack-------------------
			//Delete entry from database for the number type.
			string tableName = "another_number_generator";
			BOSequenceNumber.LoadNumberGenClassDef(tableName);
			DatabaseConnection.CurrentConnection.ExecuteRawSql("Delete From " + tableName);
			//Create an instance of the number for a specific type of number (e.g. Invoice number)
			//---------------Set up test pack-------------------
			INumberGenerator numGen = new NumberGenerator("tmp", tableName);
			//---------------Execute Test ----------------------
			//get the next number for invoice number
			long sequenceNumber = numGen.NextNumber();
			//---------------Test Result -----------------------
			//test number should be one.
			Assert.AreEqual(1, sequenceNumber);
			//---------------Tear Down -------------------------
		}
예제 #7
0
		private static void CleanupNumberGenerator()
		{
			BOSequenceNumber.LoadNumberGenClassDef();
			INumberGenerator numGen = new NumberGenerator("tmp");
			numGen.SetSequenceNumber(0);
		}
예제 #8
0
		public void TestGetSecondNumber_FromSeperateNumberGeneratorInstance_AfterUpdate()
		{
			//---------------Set up test pack-------------------
			CleanupNumberGenerator();
			NumberGenerator numGen = new NumberGenerator("tmp");
			//---------------Execute Test ----------------------
			numGen.NextNumber();
			numGen.Save();
			numGen = new NumberGenerator("tmp");
			long nextNum = numGen.NextNumber();
			//---------------Test Result -----------------------
			Assert.AreEqual(2, nextNum);
			//---------------Tear Down   -----------------------
		}
예제 #9
0
		public void TestGetSecondNumber_FromSeperateNumberGeneratorInstance()
		{
			//---------------Clean Up --------------------------
			CleanupNumberGenerator();
			//---------------Set up test pack-------------------
			INumberGenerator numGen1 = new NumberGenerator("tmp");
			//---------------Execute Test ----------------------
			numGen1.NextNumber();
			INumberGenerator numGen2 = new NumberGenerator("tmp");
			long nextNum = numGen2.NextNumber();
			//---------------Test Result -----------------------
			Assert.AreEqual(2, nextNum);
			//---------------Tear Down   -----------------------
		}
예제 #10
0
		public static void CleanUpContactPersonNumberGenerator_ForInMemory()
		{
			ContactPersonWithNumberGenerator.LoadDefaultClassDef();
			BOSequenceNumber.LoadNumberGenClassDef();
			INumberGenerator numGen = new NumberGenerator("GeneratedNumber");
			numGen.SetSequenceNumber(0);
		}
예제 #11
0
		public void TestAcceptance_GenerateSecondNumber_IncrementFirstNumber()
		{
			//---------------Set up test pack-------------------
			//Create an entry in the number generator table for entry type to seed with seed = 0.
			const string numberType = "tmp";
			BOSequenceNumber.LoadNumberGenClassDef();
			SetNumberGeneratorSeedZero(numberType);
			//Create an instance of the number for a specific type of number (e.g. Invoice number)
			INumberGenerator numGen = new NumberGenerator(numberType);
			//get the next number for invoice number
			numGen.NextNumber();
			//update to datasource

			//---------------Execute Test ----------------------
			//Get second number
			long nextNum = numGen.NextNumber();

			//---------------Test Result -----------------------
			//test number should be 2.
			Assert.AreEqual(2, nextNum);
		}
예제 #12
0
		public void TestAcceptance_GenerateFirstNumber_SeedNonZero()
		{
			//---------------Set up test pack-------------------
			//Create an entry in the number generator table for entry type to seed with seed = 100.
			BOSequenceNumber.LoadNumberGenClassDef();
			INumberGenerator numGen = new NumberGenerator("tmp");
			const int seedNumber = 100;
			numGen.SetSequenceNumber(seedNumber);
			//Create an instance of the number for a specific type of number (e.g. Invoice number)
			numGen = new NumberGenerator("tmp");
			//---------------Execute Test ----------------------
			//get the next number for invoice number
			long nextNumber = numGen.NextNumber();
			//---------------Test Result -----------------------
			//test number should be 101.
			Assert.AreEqual(seedNumber + 1, nextNumber);
			//---------------Tear Down -------------------------          
		}
예제 #13
0
		public void TestAcceptance_GenerateFirstNumber_NoSeed()
		{
			//Delete entry from database for the number type.
			BOSequenceNumber.LoadNumberGenClassDef();
			DatabaseConnection.CurrentConnection.ExecuteRawSql("Delete From NumberGenerator");
			//Create an instance of the number for a specific type of number (e.g. Invoice number)
			//---------------Set up test pack-------------------
			INumberGenerator numGen = new NumberGenerator("tmp");
			//---------------Execute Test ----------------------
			//get the next number for invoice number
			long sequenceNumber = numGen.NextNumber();
			//---------------Test Result -----------------------
			//test number should be one.
			Assert.AreEqual(1, sequenceNumber);
			//---------------Tear Down -------------------------          
		}