Skip to content

Commit

Permalink
Added a test for transitive project references when building a worksp…
Browse files Browse the repository at this point in the history
…ace (#159)
  • Loading branch information
daveaglick committed Jan 12, 2021
1 parent b879288 commit cd29a95
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Refactored `ProjectItem` to an interface `IProjectItem` for easier mocking/testing (#161, #162, thanks @fbd)
- Fixed .NET Framework TFM identification for .NET Core/.NET 5 and others (#163, #164, thanks @slang25)
- Automatically adds project references that didn't originally exist in the manager when building a Roslyn workspace (#159, #160, thanks @slang25)

# 3.1.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,21 @@ public void AddsProjectReferences(bool addProjectReferences, int totalProjects)
workspace.CurrentSolution.Projects.Count().ShouldBe(totalProjects, log.ToString());
}

[TestCase(false, 1)]
[TestCase(true, 4)]
public void AddsTransitiveProjectReferences(bool addProjectReferences, int totalProjects)
{
// Given
StringWriter log = new StringWriter();
IProjectAnalyzer analyzer = GetProjectAnalyzer(@"projects\TransitiveProjectReference\TransitiveProjectReference.csproj", log);

// When
Workspace workspace = analyzer.GetWorkspace(addProjectReferences);

// Then
workspace.CurrentSolution.Projects.Count().ShouldBe(totalProjects, log.ToString());
}

[Test]
public void SupportsConstants()
{
Expand Down
14 changes: 14 additions & 0 deletions tests/projects/TransitiveProjectReference/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace TransitiveProjectReference
{
public class Class1
{
public void Foo()
{
Console.WriteLine("Bar");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SdkNetCoreProjectWithReference\SdkNetCoreProjectWithReference.csproj" />
</ItemGroup>

</Project>

0 comments on commit cd29a95

Please sign in to comment.