Class MockDirectoryWrapper
This is a Directory Wrapper that adds methods
intended to be used only by unit tests.
It also adds a number of features useful for testing:
-
Instances created by NewDirectory() are tracked
to ensure they are disposed by the test.
-
When a MockDirectoryWrapper is disposed, it will throw an exception if
it has any open files against it (with a stacktrace indicating where
they were opened from).
-
When a MockDirectoryWrapper is disposed, it runs to test if
the index was corrupted.
-
MockDirectoryWrapper simulates some "features" of Windows, such as
refusing to write/delete to open files.
Inheritance
System.Object
MockDirectoryWrapper
Assembly: Lucene.Net.TestFramework.dll
Syntax
public class MockDirectoryWrapper : BaseDirectoryWrapper
Constructors
|
Improve this Doc
View Source
MockDirectoryWrapper(Random, Directory)
Declaration
public MockDirectoryWrapper(Random random, Directory delegate)
Parameters
Type |
Name |
Description |
Random |
random |
|
Directory |
delegate |
|
Fields
|
Improve this Doc
View Source
m_lockFactory
Declaration
protected LockFactory m_lockFactory
Field Value
Type |
Description |
LockFactory |
|
Properties
|
Improve this Doc
View Source
AllowRandomFileNotFoundException
Declaration
public virtual bool AllowRandomFileNotFoundException { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
AllowReadingFilesStillOpenForWrite
If set to true, you can open an inputstream on a file
that is still open for writes.
Declaration
public virtual bool AllowReadingFilesStillOpenForWrite { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
AssertNoDeleteOpenFile
Trip a test assert if there is an attempt
to delete an open file.
Declaration
public virtual bool AssertNoDeleteOpenFile { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
AssertNoUnreferencedFilesOnClose
Declaration
public virtual bool AssertNoUnreferencedFilesOnClose { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
FailOnCreateOutput
Declaration
public virtual bool FailOnCreateOutput { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Declaration
public virtual bool FailOnOpenInput { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
Declaration
public virtual int InputCloneCount { get; }
Property Value
Type |
Description |
System.Int32 |
|
|
Improve this Doc
View Source
LockFactory
Declaration
public override LockFactory LockFactory { get; }
Property Value
Type |
Description |
LockFactory |
|
|
Improve this Doc
View Source
MaxSizeInBytes
Declaration
public virtual long MaxSizeInBytes { get; set; }
Property Value
Type |
Description |
System.Int64 |
|
|
Improve this Doc
View Source
MaxUsedSizeInBytes
Returns the peek actual storage used (bytes) in this
directory.
Declaration
public virtual long MaxUsedSizeInBytes { get; }
Property Value
Type |
Description |
System.Int64 |
|
|
Improve this Doc
View Source
NoDeleteOpenFile
Emulate Windows whereby deleting an open file is not
allowed (raise ).
Declaration
public virtual bool NoDeleteOpenFile { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
PreventDoubleWrite
Declaration
public virtual bool PreventDoubleWrite { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
RandomIOExceptionRate
If 0.0, no exceptions will be thrown. Else this should
be a double 0.0 - 1.0. We will randomly throw an
on the first write to a based
on this probability.
Declaration
public virtual double RandomIOExceptionRate { get; set; }
Property Value
Type |
Description |
System.Double |
|
|
Improve this Doc
View Source
RandomIOExceptionRateOnOpen
Declaration
public virtual double RandomIOExceptionRateOnOpen { get; set; }
Property Value
Type |
Description |
System.Double |
|
|
Improve this Doc
View Source
Throttling
Declaration
public virtual Throttling Throttling { get; set; }
Property Value
|
Improve this Doc
View Source
TrackDiskUsage
Declaration
public virtual bool TrackDiskUsage { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
WrapLockFactory
Set to false if you want to return the pure lockfactory
and not wrap it with MockLockFactoryWrapper.
Be careful if you turn this off: MockDirectoryWrapper might
no longer be able to detect if you forget to close an ,
and spit out horribly scary confusing exceptions instead of
simply telling you that.
Declaration
public virtual bool WrapLockFactory { get; set; }
Property Value
Type |
Description |
System.Boolean |
|
Methods
|
Improve this Doc
View Source
ClearCrash()
Declaration
public virtual void ClearCrash()
|
Improve this Doc
View Source
ClearLock(String)
Declaration
public override void ClearLock(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
|
Improve this Doc
View Source
Copy(Directory, String, String, IOContext)
Declaration
public override void Copy(Directory to, string src, string dest, IOContext context)
Parameters
Type |
Name |
Description |
Directory |
to |
|
System.String |
src |
|
System.String |
dest |
|
IOContext |
context |
|
Overrides
|
Improve this Doc
View Source
Crash()
Simulates a crash of OS or machine by overwriting
unsynced files.
Declaration
public virtual void Crash()
|
Improve this Doc
View Source
CreateOutput(String, IOContext)
Declaration
public override IndexOutput CreateOutput(string name, IOContext context)
Parameters
Type |
Name |
Description |
System.String |
name |
|
IOContext |
context |
|
Returns
Type |
Description |
IndexOutput |
|
|
Improve this Doc
View Source
CreateSlicer(String, IOContext)
Declaration
public override IndexInputSlicer CreateSlicer(string name, IOContext context)
Parameters
Type |
Name |
Description |
System.String |
name |
|
IOContext |
context |
|
Returns
Type |
Description |
IndexInputSlicer |
|
Overrides
|
Improve this Doc
View Source
DeleteFile(String)
Declaration
public override void DeleteFile(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
|
Improve this Doc
View Source
Dispose(Boolean)
Declaration
protected override void Dispose(bool disposing)
Parameters
Type |
Name |
Description |
System.Boolean |
disposing |
|
Overrides
|
Improve this Doc
View Source
FailOn(Failure)
Add a Failure object to the list of objects to be evaluated
at every potential failure point.
Declaration
public virtual void FailOn(Failure fail)
Parameters
|
Improve this Doc
View Source
FileExists(String)
Declaration
public override bool FileExists(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
FileLength(String)
Declaration
public override long FileLength(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
Type |
Description |
System.Int64 |
|
|
Improve this Doc
View Source
GetLockID()
Declaration
public override string GetLockID()
Returns
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
GetOpenDeletedFiles()
Declaration
public virtual ICollection<string> GetOpenDeletedFiles()
Returns
Type |
Description |
ICollection<System.String> |
|
|
Improve this Doc
View Source
GetRecomputedActualSizeInBytes()
Like GetRecomputedSizeInBytes(), but, uses actual file
lengths rather than buffer allocations (which are
quantized up to nearest
(now 1024) bytes.
Declaration
public long GetRecomputedActualSizeInBytes()
Returns
Type |
Description |
System.Int64 |
|
|
Improve this Doc
View Source
GetRecomputedSizeInBytes()
Declaration
public long GetRecomputedSizeInBytes()
Returns
Type |
Description |
System.Int64 |
|
|
Improve this Doc
View Source
GetSizeInBytes()
Declaration
public long GetSizeInBytes()
Returns
Type |
Description |
System.Int64 |
|
|
Improve this Doc
View Source
ListAll()
Declaration
public override string[] ListAll()
Returns
Type |
Description |
System.String[] |
|
|
Improve this Doc
View Source
MakeLock(String)
Declaration
public override Lock MakeLock(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
|
Improve this Doc
View Source
OpenInput(String, IOContext)
Declaration
public override IndexInput OpenInput(string name, IOContext context)
Parameters
Type |
Name |
Description |
System.String |
name |
|
IOContext |
context |
|
Returns
Type |
Description |
IndexInput |
|
|
Improve this Doc
View Source
Declaration
public virtual void RemoveIndexInput(IndexInput in, string name)
Parameters
Type |
Name |
Description |
IndexInput |
in |
|
System.String |
name |
|
|
Improve this Doc
View Source
RemoveIndexOutput(IndexOutput, String)
Declaration
public virtual void RemoveIndexOutput(IndexOutput out, string name)
Parameters
Type |
Name |
Description |
IndexOutput |
out |
|
System.String |
name |
|
|
Improve this Doc
View Source
ResetMaxUsedSizeInBytes()
Declaration
public virtual void ResetMaxUsedSizeInBytes()
|
Improve this Doc
View Source
SetLockFactory(LockFactory)
Declaration
public override void SetLockFactory(LockFactory lockFactory)
Parameters
Type |
Name |
Description |
LockFactory |
lockFactory |
|
|
Improve this Doc
View Source
Sync(ICollection<String>)
Declaration
public override void Sync(ICollection<string> names)
Parameters
Type |
Name |
Description |
ICollection<System.String> |
names |
|