Dispose FileWatcher in tests

This commit is contained in:
Brennan 2015-11-30 14:39:01 -08:00
parent 208f0f8a58
commit 206b7b9113
1 changed files with 24 additions and 22 deletions

View File

@ -87,8 +87,8 @@ namespace Microsoft.AspNet.Diagnostics
// Arrange // Arrange
var rootPath = Directory.GetCurrentDirectory(); var rootPath = Directory.GetCurrentDirectory();
// PhysicalFileProvider handles only relative paths but we fall back to work with absolute paths too // PhysicalFileProvider handles only relative paths but we fall back to work with absolute paths too
var provider = new PhysicalFileProvider(rootPath); using (var provider = new PhysicalFileProvider(rootPath))
{
// Act // Act
var middleware = GetErrorPageMiddleware(provider); var middleware = GetErrorPageMiddleware(provider);
var stackFrame = middleware.GetStackFrame("func1", absoluteFilePath, lineNumber: 10); var stackFrame = middleware.GetStackFrame("func1", absoluteFilePath, lineNumber: 10);
@ -100,6 +100,7 @@ namespace Microsoft.AspNet.Diagnostics
Assert.Equal(GetCodeLines(10, 10), stackFrame.ContextCode); Assert.Equal(GetCodeLines(10, 10), stackFrame.ContextCode);
Assert.Equal(GetCodeLines(11, 16), stackFrame.PostContextCode); Assert.Equal(GetCodeLines(11, 16), stackFrame.PostContextCode);
} }
}
[Theory] [Theory]
[MemberData(nameof(RelativePathsData))] [MemberData(nameof(RelativePathsData))]
@ -107,8 +108,8 @@ namespace Microsoft.AspNet.Diagnostics
{ {
// Arrange // Arrange
var rootPath = Directory.GetCurrentDirectory(); var rootPath = Directory.GetCurrentDirectory();
var provider = new PhysicalFileProvider(rootPath); using (var provider = new PhysicalFileProvider(rootPath))
{
// Act // Act
var middleware = GetErrorPageMiddleware(provider); var middleware = GetErrorPageMiddleware(provider);
var stackFrame = middleware.GetStackFrame("func1", relativePath, lineNumber: 10); var stackFrame = middleware.GetStackFrame("func1", relativePath, lineNumber: 10);
@ -120,6 +121,7 @@ namespace Microsoft.AspNet.Diagnostics
Assert.Equal(GetCodeLines(10, 10), stackFrame.ContextCode); Assert.Equal(GetCodeLines(10, 10), stackFrame.ContextCode);
Assert.Equal(GetCodeLines(11, 16), stackFrame.PostContextCode); Assert.Equal(GetCodeLines(11, 16), stackFrame.PostContextCode);
} }
}
[Theory] [Theory]
[InlineData("TestFiles/EmbeddedSourceFile.txt")] [InlineData("TestFiles/EmbeddedSourceFile.txt")]