Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
</PropertyGroup>

<ItemGroup>
<None Include="Resources\confuser-empty.expected.crproj">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Resources\confuser.expected.crproj">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Resources\confuser.src.crproj">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand All @@ -21,15 +15,13 @@
<ItemGroup Label="Nuget Dependencies">
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="17.11.48" PrivateAssets="all" />
<PackageReference Include="Verify.XunitV3" Version="31.13.5" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Confuser.UnitTest\Confuser.UnitTest.csproj" />
<ProjectReference Include="..\..\Confuser.MSBuild.Tasks\Confuser.MSBuild.Tasks.csproj" />
</ItemGroup>

<ItemGroup Label="Nuget Dependencies">
<PackageReference Include="xunit.v3" Version="3.2.2" />
</ItemGroup>

</Project>
44 changes: 26 additions & 18 deletions Tests/Confuser.MSBuild.Tasks.Tests/CreateProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,41 @@
using Confuser.UnitTest;
using Microsoft.Build.Framework;
using Moq;
using VerifyTests;
using VerifyXunit;
using Xunit;

namespace Confuser.MSBuild.Tasks.Tests {
public class CreateProjectTests {
public class CreateProjectTests : VerifyBase {
private readonly ITestOutputHelper outputHelper;
private Mock<IBuildEngine> buildEngine;
private List<BuildErrorEventArgs> errors;

public CreateProjectTests(ITestOutputHelper outputHelper) {
static CreateProjectTests() {
// To disable Visual Studio popping up on every test execution.
Environment.SetEnvironmentVariable("DiffEngine_Disabled", "true");
Environment.SetEnvironmentVariable("Verify_DisableClipboard", "true");

// To prevent from adding UTF-8 BOM to generated test data:
VerifierSettings.UseUtf8NoBom();
}

public CreateProjectTests(ITestOutputHelper outputHelper) : base() {
this.outputHelper = outputHelper ?? throw new ArgumentNullException(nameof(outputHelper));
this.buildEngine = new Mock<IBuildEngine>();
this.errors = new List<BuildErrorEventArgs>();
this.buildEngine.Setup(x => x.LogErrorEvent(It.IsAny<BuildErrorEventArgs>())).Callback<BuildErrorEventArgs>(e => errors.Add(e));
}



[Fact]
[Trait("Category", "MSBuildIntegration")]
public void CreateNewProjectIfNoSourceProject() {
public async System.Threading.Tasks.Task CreateNewProjectIfNoSourceProject() {
var assembly = new Mock<ITaskItem>();
assembly.SetupAllProperties();
assembly.Object.ItemSpec = $".\\bin\\debug\\test.dll";
var baseDirectory = new Mock<ITaskItem>();
baseDirectory.SetupAllProperties();
baseDirectory.Object.ItemSpec = $".";
baseDirectory.Object.ItemSpec = $"1.";
var resultProject = new Mock<ITaskItem>();
resultProject.SetupAllProperties();
resultProject.Object.ItemSpec = $"result-empty.crproj";
Expand All @@ -48,17 +57,12 @@ public void CreateNewProjectIfNoSourceProject() {
Assert.True(success);
Assert.Empty(errors);
Assert.True(File.Exists(task.ResultProject.ItemSpec));
Assert.Collection(
File.ReadLines(".\\Resources\\confuser-empty.expected.crproj"),
File.ReadLines(task.ResultProject.ItemSpec)
.Select<string, Action<string>>((string actual) => (string expected) => Assert.Equal(expected, actual))
.ToArray()
);
await Verify(File.ReadAllText(task.ResultProject.ItemSpec), GetSettings());
}

[Fact]
[Trait("Category", "MSBuildIntegration")]
public void BaseDirectoryOverridenTest() {
public async System.Threading.Tasks.Task BaseDirectoryOverridenTest() {
var sourceProject = new Mock<ITaskItem>();
sourceProject.SetupAllProperties();
sourceProject.Object.ItemSpec = $".\\Resources\\confuser.src.crproj";
Expand Down Expand Up @@ -86,11 +90,15 @@ public void BaseDirectoryOverridenTest() {
Assert.True(success);
Assert.Empty(errors);
Assert.True(File.Exists(task.ResultProject.ItemSpec));
Assert.Collection(File.ReadLines(task.ResultProject.ItemSpec),
File.ReadLines(".\\Resources\\confuser.expected.crproj")
.Select<string, Action<string>>((string actual) => (string expected) => Assert.Equal(expected, actual))
.ToArray()
);
await Verify(File.ReadAllText(task.ResultProject.ItemSpec), GetSettings());
}

protected static VerifySettings GetSettings(params object[] parameters) {
var settings = new VerifySettings();
settings.UseDirectory("verified");
if (parameters.Length > 0)
settings.UseParameters(parameters);
return settings;
}
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<project outputDir="c:\obfuscation\output" baseDir=".\bin\debug" debug="true" xmlns="http://confuser.codeplex.com">
<module path="c:\obfuscation\input\test.dll" />
<module path="c:\obfuscation\input\test2.dll" />
<module path="test.dll" />
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<project outputDir="" baseDir=".\bin\debug" xmlns="http://confuser.codeplex.com">
<module path="test.dll" />
</project>
Loading