This class helps unit testing of modules that depend on VcClient.VC stream related functions.
Instead of streams on remote server it creates files in local directory and overrides default
API to emulate Cosmos workflow.
This class is not thread-safe.
Examples
General usage:
CopyC#
// Initialize stream manager (using is required to destroy cosmos local directory after test) // You can also consider to create this object once for test class. // using (VirtualStreamManager streamManager = new VirtualStreamManager()) { VC.Override.Attach(streamManager); try { // Run tested method here, like // MyClass.CreateReportSteams(); // Manipulate streams // streamManager.Delete("/my/stream"); // Run other tested method // MyClass.VerifyReportStreamsExist(); ... } finally { VC.Override.Clear(); } Assert.AreEqual(0, streamManager.OpenedStreams.Count); }
The VirtualStreamManager..::..ReadOnlyStream type exposes the following members.
Constructors
Name | Description | |
---|---|---|
VirtualStreamManager..::..ReadOnlyStream |
Creates a read only file stream.
|
Methods
Name | Description | |
---|---|---|
BeginRead |
Begins an asynchronous read.
(Overrides FileStreamBeginRead(array<Byte>[]()[][], Int32, Int32, AsyncCallback, Object).) | |
Read |
Reads a block of bytes from the stream and writes the data in a given buffer.
(Overrides FileStreamRead(array<Byte>[]()[][], Int32, Int32).) | |
ReadByte |
Reads a byte from the file and advances the read position one byte.
(Overrides FileStreamReadByte()()()().) | |
Seek |
Sets the current position of this stream to the given value.
(Overrides FileStreamSeek(Int64, SeekOrigin).) |
Properties
Name | Description | |
---|---|---|
Length |
Length of stream. Same as passed on constructor.
(Overrides FileStreamLength()()()().) | |
Position |
Current position of cursor in stream.
(Overrides FileStreamPosition()()()().) |