Skip to content

Commit

Permalink
Unskip all tests (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom authored Oct 1, 2021
1 parent 51942bd commit deaf5ff
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Exercism.TestRunner.CSharp/TestsRewriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ private static SyntaxNode CaptureConsoleOutput(this SyntaxNode testsRoot) =>

private class UnskipTestsRewriter : CSharpSyntaxRewriter
{
public override SyntaxNode VisitAttribute(AttributeSyntax node) =>
base.VisitAttribute(node.Name.ToString() == "Fact" ? node.WithArgumentList(null) : node);
public override SyntaxNode VisitAttributeArgument(AttributeArgumentSyntax node) =>
node.NameEquals?.Name.Identifier.Text == "Skip" ? null : base.VisitAttributeArgument(node);
}

private class CaptureConsoleOutputRewriter : CSharpSyntaxRewriter
Expand Down
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,12 @@
public static class Fake
{
public static int Identity(int x) => x;

public static int Add(int x, int y) => x + y;

public static int Sub(int x, int y) => x - y;

public static int Mul(int x, int y) => x * y;

public static int Div(int x, int y) => x / y;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<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" />
<PackageReference Include="FsCheck" Version="2.16.3" />
<PackageReference Include="FsCheck.Xunit" Version="2.16.3" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;

using Xunit;
using FsCheck.Xunit;
using FsCheck;

public class FakeTests
{
[Fact]
public void Identity() =>
Assert.Equal(2, Fake.Identity(2));

[Fact(Skip = "Remove this Skip property to run this test")]
public void Add_should_add_numbers() =>
Assert.Equal(2, Fake.Add(1, 1));

[Theory(Skip = "Remove this Skip property to run this test")]
[InlineData(4, 7, 3)]
public void Sub_should_subtract_numbers(int expected, int x, int y) =>
Assert.Equal(expected, Fake.Sub(x, y));

[CustomPropertyAttribute(Skip = "Remove this Skip property to run this test")]
public void Mul_should_multiply_numbers(int x, int y) =>
Assert.Equal(x * y, Fake.Mul(x, y));

[Property(Skip = "Remove this Skip property to run this test")]
public Property Div_should_divide_numbers(int x) =>
Prop.Throws<DivideByZeroException, int>(new Lazy<int>(() => x / 0));
}

public class CustomPropertyAttribute : PropertyAttribute
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"version": 3,
"status": "pass",
"tests": [
{
"name": "Identity",
"status": "pass",
"test_code": "Assert.Equal(2, Fake.Identity(2))"
},
{
"name": "Add should add numbers",
"status": "pass",
"test_code": "Assert.Equal(2, Fake.Add(1, 1))"
},
{
"name": "Sub should subtract numbers",
"status": "pass",
"test_code": "Assert.Equal(expected, Fake.Sub(x, y))"
},
{
"name": "Mul should multiply numbers",
"status": "pass",
"output": "Ok, passed 100 tests.",
"test_code": "Assert.Equal(x * y, Fake.Mul(x, y))"
},
{
"name": "Div should divide numbers",
"status": "pass",
"output": "Ok, passed 100 tests.",
"test_code": "Prop.Throws\u003CDivideByZeroException, int\u003E(new Lazy\u003Cint\u003E(() =\u003E x / 0))"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,12 @@ public void UseTimeZones()
var testRun = TestSolutionRunner.Run("UseTimeZones");
Assert.Equal(testRun.Expected, testRun.Actual);
}

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

0 comments on commit deaf5ff

Please sign in to comment.