/// <summary> /// Makes sure that the initialization can detect the backup /// number correctly. /// </summary> /// <param name="iBackups"></param> /// <param name="iMaxSizeRollBackups"></param> public void VerifyInitializeRollBackups(int iBackups, int iMaxSizeRollBackups) { string sBaseFile = "LogFile.log"; ArrayList arrFiles = new ArrayList(); arrFiles.Add( "junk1" ); for( int i=0; i<iBackups; i++ ) { arrFiles.Add( MakeFileName(sBaseFile, i) ); } RollingFileAppender rfa = new RollingFileAppender(); rfa.RollingStyle = RollingMode.Size; rfa.m_maxSizeRollBackups = iMaxSizeRollBackups; rfa.m_curSizeRollBackups = 0; rfa.InitializeRollBackups( sBaseFile, arrFiles ); // iBackups / Meaning // 0 = none // 1 = file.log // 2 = file.log.1 // 3 = file.log.2 if (0 == iBackups || 1 == iBackups ) { Assertion.AssertEquals( 0, rfa.m_curSizeRollBackups ); } else { Assertion.AssertEquals( Math.Min( iBackups-1, iMaxSizeRollBackups), rfa.m_curSizeRollBackups ); } }
private void InitializeAndVerifyExpectedValue( ArrayList alFiles, string sBaseFile, RollingFileAppender rfa, int iExpectedValue ) { rfa.InitializeRollBackups( sBaseFile, alFiles ); Assertion.AssertEquals( iExpectedValue, rfa.m_curSizeRollBackups ); }