public void Test_TAccountPeriodToNewYear() { // create new ledger which is in year 2010 int intLedgerNumber2010 = CommonNUnitFunctions.CreateNewLedger(new DateTime(2010, 1, 1)); // We are in 2010 and this and 2011 is not a leap year TVerificationResultCollection verificationResult = new TVerificationResultCollection(); TAccountPeriodToNewYear accountPeriodToNewYear = new TAccountPeriodToNewYear(intLedgerNumber2010); accountPeriodToNewYear.VerificationResultCollection = verificationResult; accountPeriodToNewYear.IsInInfoMode = false; // RunEndOfPeriodOperation ... accountPeriodToNewYear.RunOperation(); TAccountPeriodInfo accountPeriodInfo = new TAccountPeriodInfo(intLedgerNumber2010); accountPeriodInfo.AccountingPeriodNumber = 2; Assert.AreEqual(2011, accountPeriodInfo.PeriodStartDate.Year, "Test of the year"); Assert.AreEqual(28, accountPeriodInfo.PeriodEndDate.Day, "Test of the Feb. 28th"); // Switch to 2012 - this is a leap year ... accountPeriodToNewYear = new TAccountPeriodToNewYear(intLedgerNumber2010); accountPeriodToNewYear.IsInInfoMode = false; accountPeriodToNewYear.RunOperation(); accountPeriodInfo = new TAccountPeriodInfo(intLedgerNumber2010); accountPeriodInfo.AccountingPeriodNumber = 2; Assert.AreEqual(29, accountPeriodInfo.PeriodEndDate.Day, "Test of the Feb. 29th"); }
public void Test_TAccountPeriodToNewYear() { // create new ledger which is in year 2010 int intLedgerNumber2010 = CommonNUnitFunctions.CreateNewLedger(new DateTime(2010, 1, 1)); TDBTransaction transaction = new TDBTransaction(); TDataBase db = DBAccess.Connect("Test_TAccountPeriodToNewYear"); bool SubmissionOK = false; TAccountPeriodToNewYear accountPeriodToNewYear = null; db.WriteTransaction( ref transaction, ref SubmissionOK, delegate { // We are in 2010 and this and 2011 is not a leap year TVerificationResultCollection verificationResult = new TVerificationResultCollection(); accountPeriodToNewYear = new TAccountPeriodToNewYear(intLedgerNumber2010, transaction); accountPeriodToNewYear.VerificationResultCollection = verificationResult; accountPeriodToNewYear.IsInInfoMode = false; // RunEndOfPeriodOperation ... accountPeriodToNewYear.RunOperation(); SubmissionOK = true; }); TAccountPeriodInfo accountPeriodInfo = new TAccountPeriodInfo(intLedgerNumber2010); accountPeriodInfo.AccountingPeriodNumber = 2; Assert.AreEqual(2011, accountPeriodInfo.PeriodStartDate.Year, "Test of the year"); Assert.AreEqual(28, accountPeriodInfo.PeriodEndDate.Day, "Test of the Feb. 28th"); SubmissionOK = false; db.WriteTransaction( ref transaction, ref SubmissionOK, delegate { // Switch to 2012 - this is a leap year ... accountPeriodToNewYear = new TAccountPeriodToNewYear(intLedgerNumber2010, transaction); accountPeriodToNewYear.IsInInfoMode = false; accountPeriodToNewYear.RunOperation(); SubmissionOK = true; }); accountPeriodInfo = new TAccountPeriodInfo(intLedgerNumber2010); accountPeriodInfo.AccountingPeriodNumber = 2; Assert.AreEqual(29, accountPeriodInfo.PeriodEndDate.Day, "Test of the Feb. 29th"); }