DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
MockStream.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "Common.h"
7#include "System/IO/Stream.h"
9
10namespace DotNetDupe {
11 namespace System {
12 namespace IO {
13
20 class MockStream : public Stream {
21 private:
22 struct Impl;
23 Impl* m_pImpl;
24
25 public:
30 DOTNETDUPE_API MockStream(bool bCanRead = true, bool bCanWrite = true, bool bCanSeek = true);
31
33 DOTNETDUPE_API virtual ~MockStream() override;
34
37 DOTNETDUPE_API void SetThrowOnRead(bool bThrow);
38
41 DOTNETDUPE_API void SetThrowOnWrite(bool bThrow);
42
45 DOTNETDUPE_API void SetCanRead(bool bCanRead);
46
49 DOTNETDUPE_API void SetCanWrite(bool bCanWrite);
50
53 DOTNETDUPE_API void SetCanSeek(bool bCanSeek);
54
57 DOTNETDUPE_API bool IsDisposed() const;
58
61 DOTNETDUPE_API bool CanRead() const override;
62
65 DOTNETDUPE_API bool CanSeek() const override;
66
69 DOTNETDUPE_API bool CanWrite() const override;
70
73 DOTNETDUPE_API long GetLength() const override;
74
77 DOTNETDUPE_API long GetPosition() const override;
78
81 DOTNETDUPE_API void SetPosition(long lValue) override;
82
84 DOTNETDUPE_API void Flush() override;
85
91 DOTNETDUPE_API int Read(char* pBuffer, int iOffset, int iCount) override;
92
97 DOTNETDUPE_API long Seek(long lOffset, int iOrigin) override;
98
101 DOTNETDUPE_API void SetLength(long lValue) override;
102
107 DOTNETDUPE_API void Write(const char* pBuffer, int iOffset, int iCount) override;
108
110 DOTNETDUPE_API void Dispose() override;
111 };
112
113 }
114 }
115}
Defines common cross-platform macros, export decorators, and fundamental types.
#define DOTNETDUPE_API
Platform-specific linkage decoration for exporting or importing library symbols.
Definition Common.h:20
The exception that is thrown when an I/O error occurs.
void Flush() override
Clears all buffers for this stream.
int Read(char *pBuffer, int iOffset, int iCount) override
Reads a sequence of bytes from the current stream.
long Seek(long lOffset, int iOrigin) override
Sets the position within the current stream.
bool CanSeek() const override
Gets a value indicating whether the current stream supports seeking.
void Dispose() override
Closes and releases all resources associated with the stream.
void Write(const char *pBuffer, int iOffset, int iCount) override
Writes a sequence of bytes to the current stream.
void SetCanSeek(bool bCanSeek)
Sets whether seeking is supported.
void SetCanWrite(bool bCanWrite)
Sets whether write operations are supported.
void SetCanRead(bool bCanRead)
Sets whether read operations are supported.
long GetLength() const override
Gets the length in bytes of the stream.
bool IsDisposed() const
Checks whether the stream has been disposed.
void SetThrowOnRead(bool bThrow)
Configures whether future read operations throw an IOException.
void SetPosition(long lValue) override
Sets the current position within the stream.
void SetThrowOnWrite(bool bThrow)
Configures whether future write operations throw an IOException.
bool CanWrite() const override
Gets a value indicating whether the current stream supports writing.
MockStream(bool bCanRead=true, bool bCanWrite=true, bool bCanSeek=true)
Initializes a new instance of MockStream with configurable capabilities.
bool CanRead() const override
Gets a value indicating whether the current stream supports reading.
void SetLength(long lValue) override
Sets the length of the current stream.
long GetPosition() const override
Gets the current position within the stream.
Provides a generic view of a sequence of bytes.
Definition Stream.h:16