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 Lucene.Net.Index.CheckIndex 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
Lucene.Net.Store.Directory
Lucene.Net.Store.FilterDirectory
MockDirectoryWrapper
Implements
System.IDisposable
Inherited Members
Lucene.Net.Store.FilterDirectory.m_input
Lucene.Net.Store.FilterDirectory.Delegate
Lucene.Net.Store.FilterDirectory.ToString()
Lucene.Net.Store.Directory.OpenChecksumInput(System.String, Lucene.Net.Store.IOContext)
Lucene.Net.Store.Directory.Dispose()
Lucene.Net.Store.Directory.EnsureOpen()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Assembly: Lucene.Net.TestFramework.dll
Syntax
public class MockDirectoryWrapper : BaseDirectoryWrapper, IDisposable
Constructors
|
Improve this Doc
View Source
MockDirectoryWrapper(Random, Directory)
Declaration
public MockDirectoryWrapper(Random random, Directory delegate)
Parameters
Type |
Name |
Description |
System.Random |
random |
|
Lucene.Net.Store.Directory |
delegate |
|
Fields
|
Improve this Doc
View Source
m_lockFactory
Declaration
protected LockFactory m_lockFactory
Field Value
Type |
Description |
Lucene.Net.Store.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 |
Lucene.Net.Store.LockFactory |
|
Overrides
Lucene.Net.Store.FilterDirectory.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 System.IO.IOException).
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
System.IO.IOException on the first write to a System.IO.Stream 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 Lucene.Net.Index.IndexWriter,
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 |
|
Overrides
Lucene.Net.Store.FilterDirectory.ClearLock(System.String)
|
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 |
Lucene.Net.Store.Directory |
to |
|
System.String |
src |
|
System.String |
dest |
|
Lucene.Net.Store.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 |
|
Lucene.Net.Store.IOContext |
context |
|
Returns
Type |
Description |
Lucene.Net.Store.IndexOutput |
|
Overrides
Lucene.Net.Store.FilterDirectory.CreateOutput(System.String, Lucene.Net.Store.IOContext)
|
Improve this Doc
View Source
CreateSlicer(String, IOContext)
Declaration
public override Directory.IndexInputSlicer CreateSlicer(string name, IOContext context)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Lucene.Net.Store.IOContext |
context |
|
Returns
Type |
Description |
Lucene.Net.Store.Directory.IndexInputSlicer |
|
Overrides
|
Improve this Doc
View Source
DeleteFile(String)
Declaration
public override void DeleteFile(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Overrides
Lucene.Net.Store.FilterDirectory.DeleteFile(System.String)
|
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
[Obsolete("this method will be removed in 5.0")]
public override bool FileExists(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
Lucene.Net.Store.FilterDirectory.FileExists(System.String)
|
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 |
|
Overrides
Lucene.Net.Store.FilterDirectory.FileLength(System.String)
|
Improve this Doc
View Source
GetLockID()
Declaration
public override string GetLockID()
Returns
Type |
Description |
System.String |
|
Overrides
Lucene.Net.Store.FilterDirectory.GetLockID()
|
Improve this Doc
View Source
GetOpenDeletedFiles()
Declaration
public virtual ICollection<string> GetOpenDeletedFiles()
Returns
Type |
Description |
System.Collections.Generic.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
Lucene.Net.Store.RAMOutputStream.BUFFER_SIZE (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[] |
|
Overrides
Lucene.Net.Store.FilterDirectory.ListAll()
|
Improve this Doc
View Source
MakeLock(String)
Declaration
public override Lock MakeLock(string name)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Returns
Type |
Description |
Lucene.Net.Store.Lock |
|
Overrides
Lucene.Net.Store.FilterDirectory.MakeLock(System.String)
|
Improve this Doc
View Source
OpenInput(String, IOContext)
Declaration
public override IndexInput OpenInput(string name, IOContext context)
Parameters
Type |
Name |
Description |
System.String |
name |
|
Lucene.Net.Store.IOContext |
context |
|
Returns
Type |
Description |
Lucene.Net.Store.IndexInput |
|
Overrides
Lucene.Net.Store.FilterDirectory.OpenInput(System.String, Lucene.Net.Store.IOContext)
|
Improve this Doc
View Source
Declaration
public virtual void RemoveIndexInput(IndexInput in, string name)
Parameters
Type |
Name |
Description |
Lucene.Net.Store.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 |
Lucene.Net.Store.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 |
Lucene.Net.Store.LockFactory |
lockFactory |
|
Overrides
Lucene.Net.Store.FilterDirectory.SetLockFactory(Lucene.Net.Store.LockFactory)
|
Improve this Doc
View Source
Sync(ICollection<String>)
Declaration
public override void Sync(ICollection<string> names)
Parameters
Type |
Name |
Description |
System.Collections.Generic.ICollection<System.String> |
names |
|
Overrides
Lucene.Net.Store.FilterDirectory.Sync(System.Collections.Generic.ICollection<System.String>)
Implements
System.IDisposable