[JEDI.NET-commits] nunit/source Jedi.IO.IniFiles.NUnit.pas,1.2,1.3
Status: Pre-Alpha
Brought to you by:
jedi_mbe
From: Marcel B. <jed...@us...> - 2005-01-25 10:27:47
|
Update of /cvsroot/jedidotnet/nunit/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3468/nunit/source Modified Files: Jedi.IO.IniFiles.NUnit.pas Log Message: Updated BufferedIniFile to use the EventScheduler to schedule the AutoReload and AutoFlush. Index: Jedi.IO.IniFiles.NUnit.pas =================================================================== RCS file: /cvsroot/jedidotnet/nunit/source/Jedi.IO.IniFiles.NUnit.pas,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Jedi.IO.IniFiles.NUnit.pas 23 Jan 2005 11:08:50 -0000 1.2 --- Jedi.IO.IniFiles.NUnit.pas 25 Jan 2005 10:27:35 -0000 1.3 *************** *** 57,73 **** lastWriteDate: DateTime; begin ! ini := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, 2000); lastWriteDate := &File.GetLastWriteTimeUtc(mainIniFilePath); ! Thread.Sleep(2100); // Slightly longer than the AutoFlush interval. Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush with no changes.'); ini.Write('[AutoFlush]', 'LastWriteDate', lastWriteDate); Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush directly after changes.'); ! Thread.Sleep(1000); // Less than the AutoFlush interval. ! Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush 1s after changes.'); ! Thread.Sleep(1000); // Together with previous sleep cycles, slightly longer than the AutoFlush interval. ! Assert.IsTrue(lastWriteDate< &File.GetLastWriteTimeUtc(mainIniFilePath), 'no AutoFlush 2s after changes.'); lastWriteDate := &File.GetLastWriteTimeUtc(mainIniFilePath); ! Thread.Sleep(2100); // Slightly longer than the AutoFlush interval. ! Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush 4s after changes.'); end; --- 57,71 ---- lastWriteDate: DateTime; begin ! ini := BufferedIniFile.Create(mainIniFilePath, 0, 100); lastWriteDate := &File.GetLastWriteTimeUtc(mainIniFilePath); ! Thread.Sleep(110); // Slightly longer than the AutoFlush interval. Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush with no changes.'); ini.Write('[AutoFlush]', 'LastWriteDate', lastWriteDate); Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush directly after changes.'); ! Thread.Sleep(110); // Together with previous sleep cycles, slightly longer than the AutoFlush interval. ! Assert.IsTrue(lastWriteDate< &File.GetLastWriteTimeUtc(mainIniFilePath), 'no AutoFlush 100ms after changes.'); lastWriteDate := &File.GetLastWriteTimeUtc(mainIniFilePath); ! Thread.Sleep(110); // Slightly longer than the AutoFlush interval. ! Assert.AreEqual(lastWriteDate, &File.GetLastWriteTimeUtc(mainIniFilePath), 'AutoFlush 200ms after changes.'); end; *************** *** 78,96 **** ini3: BufferedIniFile; begin ! ini1 := BufferedIniFile.Create(mainIniFilePath, 500, Timeout.Infinite); ! ini2 := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, Timeout.Infinite); ini2.Write('SecondInstance', 'Value', 1.23); - Thread.Sleep(510); - Assert.IsFalse(ini1.SectionExists('SecondInstance'), 'Ini1 contains section before possible Reload.'); ini1.Write('FirstInstance', 'Value', 5.67); Assert.IsTrue(ini1.SectionExists('FirstInstance'), 'Ini1 should contain FirstInstance section.'); ! ini2.Free; ! Thread.Sleep(500); Assert.IsTrue(ini1.SectionExists('FirstInstance'), 'Ini1 should contain FirstInstance section after Reload.'); Assert.IsTrue(ini1.SectionExists('SecondInstance'), 'Ini1 should contain SecondInstance section after Reload.'); ! ini1.Free; ! ini3 := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, Timeout.Infinite); ! Assert.IsTrue(ini1.SectionExists('FirstInstance'), 'Ini3 should contain FirstInstance section.'); ! Assert.IsTrue(ini1.SectionExists('SecondInstance'), 'Ini3 should contain SecondInstance section.'); ini3.Free; end; --- 76,96 ---- ini3: BufferedIniFile; begin ! ini2 := BufferedIniFile.Create(mainIniFilePath, 0, 0); ! ini1 := BufferedIniFile.Create(mainIniFilePath, 100, 0); ini2.Write('SecondInstance', 'Value', 1.23); ini1.Write('FirstInstance', 'Value', 5.67); Assert.IsTrue(ini1.SectionExists('FirstInstance'), 'Ini1 should contain FirstInstance section.'); ! Assert.IsFalse(ini1.SectionExists('SecondInstance'), 'Ini1 contains section before possible Reload.'); ! Thread.Sleep(100); // wait a bit before flushing (otherwise the file's LastWriteTime may not change (lower resolution) ! ini2.Flush; ! ini2 := nil; ! Thread.Sleep(110); // add reload interval to allow the Reload taking place Assert.IsTrue(ini1.SectionExists('FirstInstance'), 'Ini1 should contain FirstInstance section after Reload.'); Assert.IsTrue(ini1.SectionExists('SecondInstance'), 'Ini1 should contain SecondInstance section after Reload.'); ! ini1.Flush; ! ini1 := nil; ! ini3 := BufferedIniFile.Create(mainIniFilePath, 0, 0); ! Assert.IsTrue(ini3.SectionExists('FirstInstance'), 'Ini3 should contain FirstInstance section.'); ! Assert.IsTrue(ini3.SectionExists('SecondInstance'), 'Ini3 should contain SecondInstance section.'); ini3.Free; end; *************** *** 127,131 **** ini2: BufferedIniFile; begin ! ini := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, Timeout.Infinite); Assert.IsTrue(ini.SectionExists('Basics'), 'Section ''{0}'' not found', ['Basics']); Assert.IsTrue(ini.KeyExists('MyTestString'), 'Key ''{0}'' not found.', ['MyTestString']); --- 127,131 ---- ini2: BufferedIniFile; begin ! ini := BufferedIniFile.Create(mainIniFilePath, 0, 0); Assert.IsTrue(ini.SectionExists('Basics'), 'Section ''{0}'' not found', ['Basics']); Assert.IsTrue(ini.KeyExists('MyTestString'), 'Key ''{0}'' not found.', ['MyTestString']); *************** *** 140,144 **** Assert.AreEqual(15, ini.ReadInt('New section', 'IntKey'), 'Value of [New section].IntKey incorrect.'); ini.Free; // should be written ! ini2 := BufferedIniFile.Create(mainIniFilePath, Timeout.Infinite, Timeout.Infinite); Assert.IsTrue(ini2.SectionExists('New section'), 'New section not saved.'); Assert.IsTrue(ini2.KeyExists('New section', 'IntKey'), 'IntKey not saved.'); --- 140,144 ---- Assert.AreEqual(15, ini.ReadInt('New section', 'IntKey'), 'Value of [New section].IntKey incorrect.'); ini.Free; // should be written ! ini2 := BufferedIniFile.Create(mainIniFilePath, 0, 0); Assert.IsTrue(ini2.SectionExists('New section'), 'New section not saved.'); Assert.IsTrue(ini2.KeyExists('New section', 'IntKey'), 'IntKey not saved.'); |