Skip to content

Commit

Permalink
chore: remove dependency on System.ValueTuple. (#82)
Browse files Browse the repository at this point in the history
* chore: remove dependency on System.ValueTuple.

* fix: use a class instead of Value Tuple in xunit.
  • Loading branch information
codito committed Jun 24, 2024
1 parent 16f8768 commit a4a1ee3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/JUnit.Xml.TestLogger/JUnit.Xml.TestLogger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,5 @@

<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="15.5.0" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion src/NUnit.Xml.TestLogger/NUnit.Xml.TestLogger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="15.5.0" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
</ItemGroup>

</Project>
1 change: 0 additions & 1 deletion src/Xunit.Xml.TestLogger/Xunit.Xml.TestLogger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="15.5.0" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
</ItemGroup>

</Project>
33 changes: 25 additions & 8 deletions src/Xunit.Xml.TestLogger/XunitXmlSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ orderby resultsByType.Key

foreach (var collection in collections)
{
total += collection.total;
passed += collection.passed;
failed += collection.failed;
skipped += collection.skipped;
errors += collection.error;
total += collection.Total;
passed += collection.Passed;
failed += collection.Failed;
skipped += collection.Skipped;
errors += collection.Error;

element.Add(collection.element);
element.Add(collection.Element);
}

// Handle errors
Expand Down Expand Up @@ -175,7 +175,7 @@ private static XElement CreateFailureElement(string exceptionType, string messag
return failureElement;
}

private static (XElement element, int total, int passed, int failed, int skipped, int error, TimeSpan time) CreateCollection(IGrouping<string, TestResultInfo> resultsByType, List<TestResultInfo> testResultAsError)
private static TestCollection CreateCollection(IGrouping<string, TestResultInfo> resultsByType, List<TestResultInfo> testResultAsError)
{
var element = new XElement("collection");

Expand Down Expand Up @@ -227,7 +227,7 @@ private static (XElement element, int total, int passed, int failed, int skipped
element.SetAttributeValue("name", $"Test collection for {resultsByType.Key}");
element.SetAttributeValue("time", time.TotalSeconds.ToString("F3", CultureInfo.InvariantCulture));

return (element, total, passed, failed, skipped, error, time);
return new TestCollection { Element = element, Total = total, Passed = passed, Failed = failed, Skipped = skipped, Error = error, Time = time };
}

private static bool IsError(TestResultInfo result)
Expand Down Expand Up @@ -318,5 +318,22 @@ private static string OutcomeToString(TestOutcome outcome)
return "Unknown";
}
}

private class TestCollection
{
public XElement Element { get; set; }

public int Total { get; set; }

public int Passed { get; set; }

public int Failed { get; set; }

public int Skipped { get; set; }

public int Error { get; set; }

public TimeSpan Time { get; set; }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,5 @@
<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="15.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion test/Json.TestLogger/Json.TestLogger.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="15.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
</ItemGroup>

</Project>

0 comments on commit a4a1ee3

Please sign in to comment.