@@ -97,18 +97,29 @@ public MockFileSystem() : this(_ => { }) { }
97
97
/// <summary>
98
98
/// Initializes the <see cref="MockFileSystem" /> with the <paramref name="initializationCallback" />.
99
99
/// </summary>
100
- internal MockFileSystem ( Action < Initialization > initializationCallback )
100
+ public MockFileSystem ( Action < Initialization > initializationCallback )
101
101
{
102
102
Initialization initialization = new ( ) ;
103
103
initializationCallback ( initialization ) ;
104
104
105
105
SimulationMode = initialization . SimulationMode ;
106
+ #if CAN_SIMULATE_OTHER_OS
106
107
Execute = SimulationMode == SimulationMode . Native
107
108
? new Execute ( this )
108
109
: new Execute ( this , SimulationMode ) ;
110
+ #else
111
+ if ( SimulationMode != SimulationMode . Native )
112
+ {
113
+ throw new NotSupportedException (
114
+ "Simulating other operating systems is not supported on .NET Framework" ) ;
115
+ }
116
+
117
+ Execute = new Execute ( this ) ;
118
+ #endif
109
119
StatisticsRegistration = new FileSystemStatistics ( this ) ;
110
120
using IDisposable release = StatisticsRegistration . Ignore ( ) ;
111
- RandomSystem = new MockRandomSystem ( initialization . RandomProvider ?? RandomProvider . Default ( ) ) ;
121
+ RandomSystem =
122
+ new MockRandomSystem ( initialization . RandomProvider ?? RandomProvider . Default ( ) ) ;
112
123
TimeSystem = new MockTimeSystem ( TimeProvider . Now ( ) ) ;
113
124
_pathMock = new PathMock ( this ) ;
114
125
_storage = new InMemoryStorage ( this ) ;
@@ -225,7 +236,7 @@ private void InitializeFileSystem(Initialization initialization)
225
236
/// <summary>
226
237
/// The initialization options for the <see cref="MockFileSystem" />.
227
238
/// </summary>
228
- internal class Initialization
239
+ public class Initialization
229
240
{
230
241
/// <summary>
231
242
/// The current directory.
@@ -242,10 +253,18 @@ internal class Initialization
242
253
/// </summary>
243
254
internal SimulationMode SimulationMode { get ; private set ; } = SimulationMode . Native ;
244
255
256
+ internal Initialization ( )
257
+ {
258
+ // Avoid public constructor
259
+ }
260
+
245
261
/// <summary>
246
262
/// Specify the operating system that should be simulated.
247
263
/// </summary>
248
- internal Initialization SimulatingOperatingSystem ( SimulationMode simulationMode )
264
+ #if ! CAN_SIMULATE_OTHER_OS
265
+ [ Obsolete ( "Simulating other operating systems is not supported on .NET Framework" ) ]
266
+ #endif
267
+ public Initialization SimulatingOperatingSystem ( SimulationMode simulationMode )
249
268
{
250
269
SimulationMode = simulationMode ;
251
270
return this ;
@@ -254,7 +273,7 @@ internal Initialization SimulatingOperatingSystem(SimulationMode simulationMode)
254
273
/// <summary>
255
274
/// Use the provided <paramref name="path" /> as current directory.
256
275
/// </summary>
257
- internal Initialization UseCurrentDirectory ( string path )
276
+ public Initialization UseCurrentDirectory ( string path )
258
277
{
259
278
CurrentDirectory = path ;
260
279
return this ;
@@ -263,7 +282,7 @@ internal Initialization UseCurrentDirectory(string path)
263
282
/// <summary>
264
283
/// Use <see cref="Directory.GetCurrentDirectory()" /> as current directory.
265
284
/// </summary>
266
- internal Initialization UseCurrentDirectory ( )
285
+ public Initialization UseCurrentDirectory ( )
267
286
{
268
287
CurrentDirectory = System . IO . Directory . GetCurrentDirectory ( ) ;
269
288
return this ;
@@ -272,7 +291,7 @@ internal Initialization UseCurrentDirectory()
272
291
/// <summary>
273
292
/// Use the given <paramref name="randomProvider" /> for the <see cref="RandomSystem" />.
274
293
/// </summary>
275
- internal Initialization UseRandomProvider ( IRandomProvider randomProvider )
294
+ public Initialization UseRandomProvider ( IRandomProvider randomProvider )
276
295
{
277
296
RandomProvider = randomProvider ;
278
297
return this ;
0 commit comments