Skip to content
Permalink
Browse files

DirectoryWatcherBase - CreateAndDispose

  • Loading branch information
bobbymcr committed Feb 10, 2020
1 parent 1297d9b commit 2facdaec338f23164899427d69c2d41af1f76731
@@ -0,0 +1,30 @@
// <copyright file="DirectoryWatcherBase.cs" company="Brian Rogers">
// Copyright (c) Brian Rogers. All rights reserved.
// </copyright>

namespace DirectoryWatcherSample
{
using System;
using System.IO;

public abstract class DirectoryWatcherBase : IDisposable
{
protected DirectoryWatcherBase(DirectoryInfo path)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
}

public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}

protected virtual void Dispose(bool disposing)
{
}
}
}
@@ -22,14 +22,21 @@ public void CreateNullPath()
act.Should().Throw<ArgumentNullException>().Which.ParamName.Should().Be("path");
}

private sealed class FakeDirectoryWatcher
[TestMethod]
public void CreateAndDispose()
{
DirectoryWatcherBase watcher = new FakeDirectoryWatcher(new DirectoryInfo(@"X:\root"));

Action act = () => watcher.Dispose();

act.Should().NotThrow();
}

private sealed class FakeDirectoryWatcher : DirectoryWatcherBase
{
public FakeDirectoryWatcher(DirectoryInfo path)
: base(path)
{
if (path == null)
{
throw new ArgumentNullException(nameof(path));
}
}
}
}

0 comments on commit 2facdae

Please sign in to comment.
You can’t perform that action at this time.