-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made FileSystemWatcher on MockFileSystem mockable (#409)
* Added set; to MockFileSystem.FileSystemWatcher * Added FILE_SYSTEM_WATCHER_NOT_IMPLEMENTED_EXCEPTION to StringResources * Made MockFileSystemWatcherFactory throw NotImplementedException * Removed MockFileSystemWatcher * MockFileSystemWatcherFactoryTests now assert exception thrown * Added MockFileSystem test to assert FileSystemWatcher is assignable * Elaborated on FILE_SYSTEM_WATCHER_NOT_IMPLEMENTED_EXCEPTION message * Corrected name of MockFileSystemWatcherFactory test * Update System.IO.Abstractions.TestingHelpers/Properties/Resources.resx Co-Authored-By: rkoeninger <rkoeninger@att.net>
- Loading branch information
1 parent
ec1b673
commit ccc8000
Showing
6 changed files
with
51 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 6 additions & 34 deletions
40
System.IO.Abstractions.TestingHelpers.Tests/MockFileSystemWatcherFactoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,24 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using XFS = System.IO.Abstractions.TestingHelpers.MockUnixSupport; | ||
|
||
namespace System.IO.Abstractions.TestingHelpers.Tests | ||
{ | ||
[TestFixture] | ||
public class MockFileSystemWatcherFactoryTests | ||
{ | ||
[Test] | ||
public void MockFileSystemWatcherFactory_CreateNew_ShouldReturnNonNullMockWatcher() | ||
public void MockFileSystemWatcherFactory_CreateNew_ShouldThrowNotImplementedException() | ||
{ | ||
// Arrange | ||
var factory = new MockFileSystemWatcherFactory(); | ||
|
||
// Act | ||
var result = factory.CreateNew(); | ||
|
||
// Assert | ||
Assert.IsNotNull(result); | ||
Assert.Throws<NotImplementedException>(() => factory.CreateNew()); | ||
} | ||
|
||
[Test] | ||
public void MockFileSystemWatcherFactory_FromPath_ShouldReturnNonNullMockWatcher() | ||
public void MockFileSystemWatcherFactory_FromPath_ShouldThrowNotImplementedException() | ||
{ | ||
// Arrange | ||
var path = XFS.Path(@"y:\test"); | ||
var factory = new MockFileSystemWatcherFactory(); | ||
|
||
// Act | ||
var result = factory.FromPath(@"y:\test"); | ||
|
||
// Assert | ||
Assert.IsNotNull(result); | ||
} | ||
|
||
[Test] | ||
public void MockFileSystemWatcherFactory_FromPath_ShouldReturnWatcherForSpecifiedPath() | ||
{ | ||
// Arrange | ||
const string path = @"z:\test"; | ||
var factory = new MockFileSystemWatcherFactory(); | ||
|
||
// Act | ||
var result = factory.FromPath(path); | ||
|
||
// Assert | ||
Assert.AreEqual(path, result.Path); | ||
Assert.Throws<NotImplementedException>(() => factory.FromPath(path)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 0 additions & 38 deletions
38
System.IO.Abstractions.TestingHelpers/MockFileSystemWatcher.cs
This file was deleted.
Oops, something went wrong.
19 changes: 5 additions & 14 deletions
19
System.IO.Abstractions.TestingHelpers/MockFileSystemWatcherFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace System.IO.Abstractions.TestingHelpers | ||
namespace System.IO.Abstractions.TestingHelpers | ||
{ | ||
[Serializable] | ||
public class MockFileSystemWatcherFactory : IFileSystemWatcherFactory | ||
{ | ||
public FileSystemWatcherBase CreateNew() | ||
{ | ||
return new MockFileSystemWatcher(); | ||
} | ||
public FileSystemWatcherBase CreateNew() => | ||
throw new NotImplementedException(StringResources.Manager.GetString("FILE_SYSTEM_WATCHER_NOT_IMPLEMENTED_EXCEPTION")); | ||
|
||
public FileSystemWatcherBase FromPath(string path) | ||
{ | ||
return new MockFileSystemWatcher {Path = path}; | ||
} | ||
public FileSystemWatcherBase FromPath(string path) => | ||
throw new NotImplementedException(StringResources.Manager.GetString("FILE_SYSTEM_WATCHER_NOT_IMPLEMENTED_EXCEPTION")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters