-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathMockDirectoryArgumentPathTests.cs
More file actions
45 lines (41 loc) · 1.89 KB
/
MockDirectoryArgumentPathTests.cs
File metadata and controls
45 lines (41 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System.Collections.Generic;
using System.Security.AccessControl;
using NUnit.Framework;
namespace System.IO.Abstractions.TestingHelpers.Tests
{
public class MockDirectoryArgumentPathTests
{
private static IEnumerable<Action<IDirectory>> GetFileSystemActionsForArgumentNullException()
{
yield return ds => ds.Delete(null);
yield return ds => ds.Delete(null, true);
yield return ds => ds.CreateDirectory(null);
if (MockUnixSupport.IsWindowsPlatform())
{
#pragma warning disable CA1416
yield return ds => ds.CreateDirectory(null, new DirectorySecurity());
#pragma warning restore CA1416
}
yield return ds => ds.SetCreationTime(null, DateTime.Now);
yield return ds => ds.SetCreationTimeUtc(null, DateTime.Now);
yield return ds => ds.SetLastAccessTime(null, DateTime.Now);
yield return ds => ds.SetLastAccessTimeUtc(null, DateTime.Now);
yield return ds => ds.SetLastWriteTime(null, DateTime.Now);
yield return ds => ds.SetLastWriteTimeUtc(null, DateTime.Now);
yield return ds => ds.EnumerateDirectories(null);
yield return ds => ds.EnumerateDirectories(null, "foo");
yield return ds => ds.EnumerateDirectories(null, "foo", SearchOption.AllDirectories);
}
[TestCaseSource(nameof(GetFileSystemActionsForArgumentNullException))]
public async Task Operations_ShouldThrowArgumentNullExceptionIfPathIsNull(Action<IDirectory> action)
{
// Arrange
var fileSystem = new MockFileSystem();
// Act
Action wrapped = () => action(fileSystem.Directory);
// Assert
var exception = await That(wrapped).Throws<ArgumentNullException>();
await That(exception.ParamName).IsEqualTo("path");
}
}
}