Skip to content

Commit

Permalink
Support running on downloaded solution (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom authored Sep 10, 2021
1 parent 3536f22 commit 72d4e18
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Exercism.TestRunner.CSharp/FilesParser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;

Expand All @@ -16,7 +17,11 @@ private static string ConfigJson(Options options) =>
File.ReadAllText(options.ConfigJsonPath());

private static string ConfigJsonPath(this Options options) =>
Path.Combine(options.InputDirectory, ".meta", "config.json");
new[]
{
Path.Combine(options.InputDirectory, ".meta", "config.json"),
Path.Combine(options.InputDirectory, ".exercism", "config.json")
}.First(File.Exists);
}

internal class Files
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public static class Fake
{
public static int Add(int x, int y) => x + y;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"files": {
"solution": ["Fake.cs"],
"test": ["FakeTests.cs"],
"example": [".meta/Example.cs"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
public static class Fake
{
public static int Add(int x, int y) => x + y;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Example.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="Exercism.Tests" Version="0.1.0-alpha" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Xunit;
public class FakeTests
{
[Fact]
public void Add_should_add_numbers() => Assert.Equal(2, Fake.Add(1, 1));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": 3,
"status": "pass",
"tests": [
{
"name": "Add should add numbers",
"status": "pass",
"test_code": "Assert.Equal(2, Fake.Add(1, 1))"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,12 @@ public void UseCultureAttribute()
var testRun = TestSolutionRunner.Run("UseCultureAttribute");
Assert.Equal(testRun.Expected, testRun.Actual);
}

[Fact]
public void DownloadedSolution()
{
var testRun = TestSolutionRunner.Run("DownloadedSolution");
Assert.Equal(testRun.Expected, testRun.Actual);
}
}
}

0 comments on commit 72d4e18

Please sign in to comment.