Removed the DIA classes and the cod associated with it. Introduced a PdbReaderFactory that decides with PdbReader to use (full or portable). Introduced a PdbReader interface that abstracts the differences between full pdb (Uses ISymUnmanaged classes to read the pdb) and portable pdb (uses Reflection MetadataReader).
This commit is contained in:
parent
811db45cf3
commit
85884c5e9a
54 changed files with 998 additions and 2555 deletions
|
@ -0,0 +1,63 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Testing.Abstractions;
|
||||
using Moq;
|
||||
using Xunit;
|
||||
using System.Reflection;
|
||||
using FluentAssertions;
|
||||
|
||||
namespace Microsoft.Extensions.Testing.Abstractions.UnitTests
|
||||
{
|
||||
public class GivenThatWeWantToUseSourceInformationProviderToGetSourceInformation
|
||||
{
|
||||
private string _pdbPath = Path.Combine(AppContext.BaseDirectory, "TestAppWithPortablePdbs.pdb");
|
||||
|
||||
[Fact]
|
||||
public void It_creates_a_pdb_reader_right_away()
|
||||
{
|
||||
var pdbReaderFactoryMock = new Mock<IPdbReaderFactory>();
|
||||
var sourceInformationProvider = new SourceInformationProvider(_pdbPath, null, pdbReaderFactoryMock.Object);
|
||||
|
||||
pdbReaderFactoryMock.Verify(p => p.Create(_pdbPath), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_uses_the_reader_to_get_the_SourceInformation()
|
||||
{
|
||||
var type = typeof(GivenThatWeWantToUseSourceInformationProviderToGetSourceInformation);
|
||||
var methodInfo = type.GetMethod("It_uses_the_reader_to_get_the_SourceInformation");
|
||||
|
||||
var expectedSourceInformation = new SourceInformation("some file path.cs", 12);
|
||||
var pdbReaderMock = new Mock<IPdbReader>();
|
||||
pdbReaderMock.Setup(p => p.GetSourceInformation(methodInfo)).Returns(expectedSourceInformation);
|
||||
|
||||
var pdbReaderFactoryMock = new Mock<IPdbReaderFactory>();
|
||||
pdbReaderFactoryMock.Setup(p => p.Create(_pdbPath)).Returns(pdbReaderMock.Object);
|
||||
|
||||
var sourceInformationProvider = new SourceInformationProvider(_pdbPath, null, pdbReaderFactoryMock.Object);
|
||||
|
||||
var actualSourceInformation = sourceInformationProvider.GetSourceInformation(methodInfo);
|
||||
|
||||
actualSourceInformation.Should().Be(expectedSourceInformation);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_disposes_of_the_reader_when_it_gets_disposed()
|
||||
{
|
||||
var pdbReaderMock = new Mock<IPdbReader>();
|
||||
|
||||
var pdbReaderFactoryMock = new Mock<IPdbReaderFactory>();
|
||||
pdbReaderFactoryMock.Setup(p => p.Create(_pdbPath)).Returns(pdbReaderMock.Object);
|
||||
|
||||
using (var sourceInformationProvider =
|
||||
new SourceInformationProvider(_pdbPath, null, pdbReaderFactoryMock.Object))
|
||||
{
|
||||
}
|
||||
|
||||
pdbReaderMock.Verify(p => p.Dispose(), Times.Once);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>deb3ab06-fcd8-4119-b8ca-b7aa6ce2f22d</ProjectGuid>
|
||||
<RootNamespace>Microsoft.Extensions.Testing.Abstractions.UnitTests</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\bin</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"version": "1.0.0-*",
|
||||
|
||||
"dependencies": {
|
||||
"NETStandard.Library": "1.5.0-rc2-23924",
|
||||
"Microsoft.Extensions.Testing.Abstractions": { "target": "project" },
|
||||
"System.Runtime.Serialization.Primitives": "4.1.1-rc2-23924",
|
||||
"System.Diagnostics.Process": "4.1.0-rc2-23924",
|
||||
"TestAppWithPortablePdbs": { "target": "project" },
|
||||
"xunit": "2.1.0",
|
||||
"dotnet-test-xunit": "1.0.0-dev-91790-12",
|
||||
"FluentAssertions": "4.2.2",
|
||||
"moq.netcore": "4.4.0-beta8"
|
||||
},
|
||||
|
||||
"frameworks": {
|
||||
"netstandardapp1.5": {
|
||||
"imports": [
|
||||
"dnxcore50",
|
||||
"netstandard1.3",
|
||||
"portable-net45+win8"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
"testRunner": "xunit"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue