Skip to content

Commit

Permalink
Merge pull request #824 from TestCentric/issue-194
Browse files Browse the repository at this point in the history
Add theories to mock-assembly for testing purposes
  • Loading branch information
CharliePoole authored Oct 2, 2021
2 parents 1b328d7 + 7023526 commit 03480b6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
8 changes: 4 additions & 4 deletions cake/package-tests.cake
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ public abstract class PackageTester : GuiTester
"mock-assembly.dll",
new ExpectedResult("Failed")
{
Total = 31,
Passed = 18,
Failed = 5,
Total = 40,
Passed = 22,
Failed = 6,
Warnings = 0,
Inconclusive = 1,
Inconclusive = 5,
Skipped = 7,
Assemblies = new[] { new ExpectedAssemblyResult("mock-assembly.dll", "net-4.5") }
})) ;
Expand Down
33 changes: 31 additions & 2 deletions src/tests/mock-assembly/MockAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Assemblies
/// </summary>
public class MockAssembly
{
public static int Classes = 9;
public static int Classes = 10;
public static int NamespaceSuites = 6; // assembly, NUnit, Tests, Assemblies, Singletons, TestAssembly

public static int Tests = MockTestFixture.Tests
Expand All @@ -26,7 +26,8 @@ public class MockAssembly
+ BadFixture.Tests
+ FixtureWithTestCases.Tests
+ ParameterizedFixture.Tests
+ GenericFixtureConstants.Tests;
+ GenericFixtureConstants.Tests
+ FixtureWithTheories.Tests;

public static int Suites = MockTestFixture.Suites
+ Singletons.OneTestCase.Suites
Expand All @@ -37,6 +38,7 @@ public class MockAssembly
+ FixtureWithTestCases.Suites
+ ParameterizedFixture.Suites
+ GenericFixtureConstants.Suites
+ FixtureWithTheories.Suites
+ NamespaceSuites;

public static readonly int Nodes = Tests + Suites;
Expand Down Expand Up @@ -280,4 +282,31 @@ public void Test1() { }
[Test]
public void Test2() { }
}

public class FixtureWithTheories
{
public static readonly int Tests = 9;
public static readonly int Suites = 3;

[DatapointSource]
static int[] ValuesToUse = new int[] { 1, 2, 3 };

[Theory]
public void AllCasesPass(int val)
{
Assume.That(val != 2, $"Argument '{val}' is not valid.");
}

[Theory]
public void AllCasesInconclusive(int val)
{
Assert.Inconclusive($"Argument '{val}' is not valid.");
}

[Theory]
public void OneCaseFails(int val)
{
Assert.That(val, Is.Not.EqualTo(2));
}
}
}

0 comments on commit 03480b6

Please sign in to comment.