Skip to content

Commit

Permalink
Upgraded abstractions dependency to 3.0.0-pre.1.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcondon committed Oct 16, 2022
1 parent d08411a commit 98a8a51
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 19 deletions.
60 changes: 54 additions & 6 deletions src/FlUnit/ActionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public override void Arrange(ITestContext testContext)
{
try
{
cases = new[] { new Case(act, makeAssertions) };
cases = new[] { new Case(this, act, makeAssertions) };
}
catch (Exception e)
{
Expand All @@ -77,13 +77,18 @@ public class Case : ITestCase
internal TestActionOutcome invocationOutcome;

internal Case(
Test test,
Action act,
Func<Case, IEnumerable<Assertion>> makeAssertions)
{
this.Test = test;
this.act = act;
this.Assertions = makeAssertions(this).ToArray();
}

/// <inheritdoc />
public Test Test { get; }

/// <inheritdoc />
public IReadOnlyCollection<ITestAssertion> Assertions { get; }

Expand Down Expand Up @@ -138,6 +143,9 @@ public class Assertion : ITestAssertion
this.description = description;
}

/// <inheritdoc />
public ITestCase TestCase => testCase;

/// <inheritdoc />
public void Assert()
{
Expand Down Expand Up @@ -223,7 +231,7 @@ public override void Arrange(ITestContext testContext)
{
try
{
cases = arrange(testContext).Select(p => new Case(p, act, makeAssertions)).ToArray();
cases = arrange(testContext).Select(p => new Case(this, p, act, makeAssertions)).ToArray();
}
catch (Exception e)
{
Expand All @@ -248,15 +256,20 @@ public class Case : ITestCase
internal TestActionOutcome invocationOutcome;

internal Case(
Test test,
T1 prereqs,
Action<T1> act,
Func<Case, IEnumerable<Assertion>> makeAssertions)
{
this.Test = test;
this.prereqs = prereqs;
this.act = act;
this.Assertions = makeAssertions(this).ToArray();
}

/// <inheritdoc />
public Test Test { get; }

/// <inheritdoc />
public IReadOnlyCollection<ITestAssertion> Assertions { get; }

Expand Down Expand Up @@ -311,6 +324,9 @@ public class Assertion : ITestAssertion
this.description = description;
}

/// <inheritdoc />
public ITestCase TestCase => testCase;

/// <inheritdoc />
public void Assert()
{
Expand Down Expand Up @@ -400,7 +416,7 @@ public override void Arrange(ITestContext testContext)
cases = (
from p1 in arrange.Item1(testContext)
from p2 in arrange.Item2(testContext)
select new Case((p1, p2), act, makeAssertions)).ToArray();
select new Case(this, (p1, p2), act, makeAssertions)).ToArray();
}
catch (Exception e)
{
Expand All @@ -425,15 +441,20 @@ public class Case : ITestCase
internal TestActionOutcome invocationOutcome;

internal Case(
Test test,
(T1, T2) prereqs,
Action<T1, T2> act,
Func<Case, IEnumerable<Assertion>> makeAssertions)
{
this.Test = test;
this.prereqs = prereqs;
this.act = act;
this.Assertions = makeAssertions(this).ToArray();
}

/// <inheritdoc />
public Test Test { get; }

/// <inheritdoc />
public IReadOnlyCollection<ITestAssertion> Assertions { get; }

Expand Down Expand Up @@ -488,6 +509,9 @@ public class Assertion : ITestAssertion
this.description = description;
}

/// <inheritdoc />
public ITestCase TestCase => testCase;

/// <inheritdoc />
public void Assert()
{
Expand Down Expand Up @@ -579,7 +603,7 @@ public override void Arrange(ITestContext testContext)
from p1 in arrange.Item1(testContext)
from p2 in arrange.Item2(testContext)
from p3 in arrange.Item3(testContext)
select new Case((p1, p2, p3), act, makeAssertions)).ToArray();
select new Case(this, (p1, p2, p3), act, makeAssertions)).ToArray();
}
catch (Exception e)
{
Expand All @@ -604,15 +628,20 @@ public class Case : ITestCase
internal TestActionOutcome invocationOutcome;

internal Case(
Test test,
(T1, T2, T3) prereqs,
Action<T1, T2, T3> act,
Func<Case, IEnumerable<Assertion>> makeAssertions)
{
this.Test = test;
this.prereqs = prereqs;
this.act = act;
this.Assertions = makeAssertions(this).ToArray();
}

/// <inheritdoc />
public Test Test { get; }

/// <inheritdoc />
public IReadOnlyCollection<ITestAssertion> Assertions { get; }

Expand Down Expand Up @@ -667,6 +696,9 @@ public class Assertion : ITestAssertion
this.description = description;
}

/// <inheritdoc />
public ITestCase TestCase => testCase;

/// <inheritdoc />
public void Assert()
{
Expand Down Expand Up @@ -760,7 +792,7 @@ public override void Arrange(ITestContext testContext)
from p2 in arrange.Item2(testContext)
from p3 in arrange.Item3(testContext)
from p4 in arrange.Item4(testContext)
select new Case((p1, p2, p3, p4), act, makeAssertions)).ToArray();
select new Case(this, (p1, p2, p3, p4), act, makeAssertions)).ToArray();
}
catch (Exception e)
{
Expand All @@ -785,15 +817,20 @@ public class Case : ITestCase
internal TestActionOutcome invocationOutcome;

internal Case(
Test test,
(T1, T2, T3, T4) prereqs,
Action<T1, T2, T3, T4> act,
Func<Case, IEnumerable<Assertion>> makeAssertions)
{
this.Test = test;
this.prereqs = prereqs;
this.act = act;
this.Assertions = makeAssertions(this).ToArray();
}

/// <inheritdoc />
public Test Test { get; }

/// <inheritdoc />
public IReadOnlyCollection<ITestAssertion> Assertions { get; }

Expand Down Expand Up @@ -848,6 +885,9 @@ public class Assertion : ITestAssertion
this.description = description;
}

/// <inheritdoc />
public ITestCase TestCase => testCase;

/// <inheritdoc />
public void Assert()
{
Expand Down Expand Up @@ -943,7 +983,7 @@ public override void Arrange(ITestContext testContext)
from p3 in arrange.Item3(testContext)
from p4 in arrange.Item4(testContext)
from p5 in arrange.Item5(testContext)
select new Case((p1, p2, p3, p4, p5), act, makeAssertions)).ToArray();
select new Case(this, (p1, p2, p3, p4, p5), act, makeAssertions)).ToArray();
}
catch (Exception e)
{
Expand All @@ -968,15 +1008,20 @@ public class Case : ITestCase
internal TestActionOutcome invocationOutcome;

internal Case(
Test test,
(T1, T2, T3, T4, T5) prereqs,
Action<T1, T2, T3, T4, T5> act,
Func<Case, IEnumerable<Assertion>> makeAssertions)
{
this.Test = test;
this.prereqs = prereqs;
this.act = act;
this.Assertions = makeAssertions(this).ToArray();
}

/// <inheritdoc />
public Test Test { get; }

/// <inheritdoc />
public IReadOnlyCollection<ITestAssertion> Assertions { get; }

Expand Down Expand Up @@ -1031,6 +1076,9 @@ public class Assertion : ITestAssertion
this.description = description;
}

/// <inheritdoc />
public ITestCase TestCase => testCase;

/// <inheritdoc />
public void Assert()
{
Expand Down
14 changes: 11 additions & 3 deletions src/FlUnit/ActionTest.tt
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ namespace FlUnit
try
{
<# if (i == 0) { #>
cases = new[] { new Case(act, makeAssertions) };
cases = new[] { new Case(this, act, makeAssertions) };
<# } else if (i == 1) { #>
cases = arrange(testContext).Select(p => new Case(p, act, makeAssertions)).ToArray();
cases = arrange(testContext).Select(p => new Case(this, p, act, makeAssertions)).ToArray();
<# } else if (i > 1) { #>
cases = (
<# for (int j = 0; j < i; j++) { #>
from p<#= j + 1 #> in arrange.Item<#= j + 1 #>(testContext)
<# } #>
select new Case((<#= List(i, i => $"p{i}") #>), act, makeAssertions)).ToArray();
select new Case(this, (<#= List(i, i => $"p{i}") #>), act, makeAssertions)).ToArray();
<# } #>
}
catch (Exception e)
Expand All @@ -102,15 +102,20 @@ namespace FlUnit
internal TestActionOutcome invocationOutcome;

internal Case(
Test test,
<# WriteLineIf(i > 0, $"{PrereqsFieldType(i)} prereqs,", 4); #>
Action<#= TList(i, "<", ">") #> act,
Func<Case, IEnumerable<Assertion>> makeAssertions)
{
this.Test = test;
<# WriteLineIf(i > 0, "this.prereqs = prereqs;", 4); #>
this.act = act;
this.Assertions = makeAssertions(this).ToArray();
}

/// <inheritdoc />
public Test Test { get; }

/// <inheritdoc />
public IReadOnlyCollection<ITestAssertion> Assertions { get; }

Expand Down Expand Up @@ -169,6 +174,9 @@ namespace FlUnit
this.description = description;
}

/// <inheritdoc />
public ITestCase TestCase => testCase;

/// <inheritdoc />
public void Assert()
{
Expand Down
2 changes: 1 addition & 1 deletion src/FlUnit/FlUnit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FlUnit.Abstractions" Version="2.0.0" />
<PackageReference Include="FlUnit.Abstractions" Version="3.0.0-pre.1" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down

0 comments on commit 98a8a51

Please sign in to comment.