Skip to content

Commit

Permalink
DirectoryWatcherBase - CreateAndDispose
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbymcr committed Feb 10, 2020
1 parent 1297d9b commit 2facdae
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
}
}
Expand Down

0 comments on commit 2facdae

Please sign in to comment.