Fixed up test failures

上级 11ff865a
......@@ -1515,7 +1515,7 @@ public class C {}";
var options = TestOptions.SigningReleaseModule.WithCryptoKeyContainer("roslynTestContainer");
var other = CreateCompilation(s, options: options);
var other = CreateCompilation(s, options: options, parseOptions: parseOptions);
var outStrm = new MemoryStream();
var success = other.Emit(outStrm);
......
......@@ -97,9 +97,10 @@ private Stream CreateStream(DiagnosticBag diagnostics)
try
{
Func<string, Stream> streamConstructor = path => new FileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
var fileSystem = _strongNameProvider.FileSystem;
Func<string, Stream> streamConstructor = path => fileSystem.CreateFileStream(path, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);
var tempDir = _strongNameProvider.FileSystem.GetTempPath();
var tempDir = fileSystem.GetTempPath();
var tempFilePath = Path.Combine(tempDir, Guid.NewGuid().ToString("N"));
var tempStream = FileUtilities.CreateFileStreamChecked(streamConstructor, tempFilePath);
......
......@@ -23,6 +23,11 @@ internal StrongNameFileSystem(string tempPath = null)
: () => tempPath;
}
internal virtual FileStream CreateFileStream(string filePath, FileMode fileMode, FileAccess fileAccess, FileShare fileShare)
{
return new FileStream(filePath, fileMode, fileAccess, fileShare);
}
internal virtual byte[] ReadAllBytes(string fullPath)
{
Debug.Assert(PathUtilities.IsAbsolute(fullPath));
......
......@@ -18,10 +18,12 @@ Partial Public Class InternalsVisibleToAndStrongNameTests
Public Sub BadInputStream()
SigningTestHelpers.InstallKey()
Dim thrownException = New IOException("This is a test IOException")
Dim testProvider = New TestDesktopStrongNameProvider() With {
.SignFileFunc = Sub(a, b) Throw thrownException
Dim testFileSystem = New TestStrongNameFileSystem() With {
.CreateFileStreamFunc = Function(filePath As String, fileMode As FileMode, fileAccess As FileAccess, fileShare As FileShare) As FileStream
Throw thrownException
End Function
}
Dim testProvider = New TestDesktopStrongNameProvider(fileSystem:=testFileSystem)
Dim options = TestOptions.DebugDll.WithStrongNameProvider(testProvider).WithCryptoKeyContainer("RoslynTestContainer")
Dim comp = CreateCompilationWithMscorlib40(
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
namespace Microsoft.CodeAnalysis.Test.Utilities
{
internal sealed class TestStrongNameFileSystem : StrongNameFileSystem
{
internal Func<string, byte[]> ReadAllBytesFunc { get; set; }
internal Func<string, FileMode, FileAccess, FileShare, FileStream> CreateFileStreamFunc { get; set; }
internal TestStrongNameFileSystem()
{
ReadAllBytesFunc = base.ReadAllBytes;
CreateFileStreamFunc = base.CreateFileStream;
}
internal override byte[] ReadAllBytes(string fullPath) => ReadAllBytesFunc(fullPath);
internal override FileStream CreateFileStream(string filePath, FileMode fileMode, FileAccess fileAccess, FileShare fileShare) =>
CreateFileStreamFunc(filePath, fileMode, fileAccess, fileShare);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册