Skip to content

Commit ab9e046

Browse files
committed
Update GitVersioning
1 parent e5a4dc6 commit ab9e046

File tree

11 files changed

+92
-173
lines changed

11 files changed

+92
-173
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,5 @@ paket-files/
258258

259259
# Python Tools for Visual Studio (PTVS)
260260
__pycache__/
261-
*.pyc
261+
*.pyc
262+
**/launchSettings.json

Directory.Build.props

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup>
4+
<PackageReference Include="Nerdbank.GitVersioning">
5+
<Version>3.0.24</Version>
6+
<PrivateAssets>all</PrivateAssets>
7+
</PackageReference>
8+
</ItemGroup>
9+
</Project>

Xunit.Priority.Tests/PriorityOrdererTests.cs

Lines changed: 14 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -5,91 +5,31 @@
55
using System.Threading.Tasks;
66
using Xunit;
77
using Xunit.Priority;
8-
using Shouldly;
8+
using FluentAssertions;
99

1010
namespace Xunit.Priority.Tests
1111
{
12-
13-
[TestCaseOrderer(PriorityOrderer.Name, PriorityOrderer.Assembly)]
14-
public class PriorityOrdererTests
12+
public class PriorityOrdererTests: TestsBase
1513
{
16-
public static bool Test1Called;
17-
public static bool Test2Called;
18-
public static bool Test3ACalled;
19-
public static bool Test3BCalled;
20-
public static bool Test4Called;
21-
public static bool Test5Called;
14+
private static bool[] _counter;
15+
2216

2317
[Fact, Priority(10)]
24-
public void Test3A()
25-
{
26-
Test3ACalled = true;
27-
28-
Test1Called.ShouldBe(true);
29-
Test2Called.ShouldBe(true);
30-
Test3BCalled.ShouldBe(false);
31-
Test4Called.ShouldBe(false);
32-
Test5Called.ShouldBe(false);
33-
}
18+
public void Test3A() => VerifyAndFlip(2);
3419

3520
[Fact, Priority(-10)]
36-
public void Test1()
37-
{
38-
Test1Called = true;
39-
40-
Test2Called.ShouldBe(false);
41-
Test3ACalled.ShouldBe(false);
42-
Test3BCalled.ShouldBe(false);
43-
Test4Called.ShouldBe(false);
44-
Test5Called.ShouldBe(false);
45-
}
46-
21+
public void Test1() => VerifyAndFlip(0);
22+
4723
[Fact]
48-
public void Test5()
49-
{
50-
Test5Called = true;
51-
52-
Test1Called.ShouldBe(true);
53-
Test2Called.ShouldBe(true);
54-
Test3ACalled.ShouldBe(true);
55-
Test3BCalled.ShouldBe(true);
56-
Test4Called.ShouldBe(true);
57-
}
58-
24+
public void Test5() => VerifyAndFlip(5);
25+
5926
[Fact, Priority(0)]
60-
public void Test2()
61-
{
62-
Test2Called = true;
63-
64-
Test1Called.ShouldBe(true);
65-
Test3ACalled.ShouldBe(false);
66-
Test3BCalled.ShouldBe(false);
67-
Test4Called.ShouldBe(false);
68-
Test5Called.ShouldBe(false);
69-
}
70-
27+
public void Test2() => VerifyAndFlip(1);
28+
7129
[Fact, Priority(20)]
72-
public void Test4()
73-
{
74-
Test4Called = true;
75-
76-
Test1Called.ShouldBe(true);
77-
Test2Called.ShouldBe(true);
78-
Test3ACalled.ShouldBe(true);
79-
Test3BCalled.ShouldBe(true);
80-
Test5Called.ShouldBe(false);
81-
}
82-
30+
public void Test4() => VerifyAndFlip(4);
31+
8332
[Fact, Priority(10)]
84-
public void Test3B()
85-
{
86-
Test3BCalled = true;
87-
88-
Test1Called.ShouldBe(true);
89-
Test2Called.ShouldBe(true);
90-
Test3ACalled.ShouldBe(true);
91-
Test4Called.ShouldBe(false);
92-
Test5Called.ShouldBe(false);
93-
}
33+
public void Test3B() => VerifyAndFlip(3);
9434
}
9535
}

Xunit.Priority.Tests/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

Xunit.Priority.Tests/TestsBase.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Reflection;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using FluentAssertions;
8+
9+
namespace Xunit.Priority.Tests
10+
{
11+
[TestCaseOrderer(PriorityOrderer.Name, PriorityOrderer.Assembly)]
12+
public abstract class TestsBase
13+
{
14+
private FieldInfo _counterField;
15+
16+
public TestsBase()
17+
{
18+
_counterField = this.GetType().GetField("_counter", BindingFlags.Static | BindingFlags.NonPublic);
19+
20+
if (GetCounter() == null)
21+
{
22+
var facts = this.GetType().GetMethods()
23+
.Where(m => m.GetCustomAttribute<FactAttribute>() != null);
24+
SetCounter(new bool[facts.Count()]);
25+
26+
}
27+
}
28+
29+
private bool[] GetCounter() => _counterField.GetValue(this) as bool[];
30+
31+
private void SetCounter(bool[] value) => _counterField.SetValue(this, value);
32+
33+
protected void VerifyAndFlip(int testNumber)
34+
{
35+
var counter = GetCounter();
36+
counter.Take(testNumber).Should().AllBeEquivalentTo(true);
37+
counter.Skip(testNumber).Should().AllBeEquivalentTo(false);
38+
39+
counter[testNumber] = true;
40+
SetCounter(counter);
41+
}
42+
}
43+
}
Lines changed: 12 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,19 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
43
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{713138AA-F9E7-4F69-A263-C8F387F5B80C}</ProjectGuid>
8-
<OutputType>Library</OutputType>
9-
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>Xunit.Priority.Tests</RootNamespace>
11-
<AssemblyName>Xunit.Priority.Tests</AssemblyName>
12-
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
13-
<FileAlignment>512</FileAlignment>
4+
<TargetFrameworks>netcoreapp2.2;net462</TargetFrameworks>
5+
6+
<IsPackable>false</IsPackable>
147
</PropertyGroup>
15-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16-
<DebugSymbols>true</DebugSymbols>
17-
<DebugType>full</DebugType>
18-
<Optimize>false</Optimize>
19-
<OutputPath>bin\Debug\</OutputPath>
20-
<DefineConstants>DEBUG;TRACE</DefineConstants>
21-
<ErrorReport>prompt</ErrorReport>
22-
<WarningLevel>4</WarningLevel>
23-
</PropertyGroup>
24-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25-
<DebugType>pdbonly</DebugType>
26-
<Optimize>true</Optimize>
27-
<OutputPath>bin\Release\</OutputPath>
28-
<DefineConstants>TRACE</DefineConstants>
29-
<ErrorReport>prompt</ErrorReport>
30-
<WarningLevel>4</WarningLevel>
31-
</PropertyGroup>
32-
<ItemGroup>
33-
<Reference Include="System" />
34-
<Reference Include="System.Core" />
35-
<Reference Include="System.Xml.Linq" />
36-
<Reference Include="System.Data.DataSetExtensions" />
37-
<Reference Include="Microsoft.CSharp" />
38-
<Reference Include="System.Data" />
39-
<Reference Include="System.Net.Http" />
40-
<Reference Include="System.Xml" />
41-
</ItemGroup>
42-
<ItemGroup>
43-
<Compile Include="PriorityOrdererTests.cs" />
44-
<Compile Include="Properties\AssemblyInfo.cs" />
45-
</ItemGroup>
8+
469
<ItemGroup>
47-
<PackageReference Include="Shouldly">
48-
<Version>2.8.3</Version>
49-
</PackageReference>
50-
<PackageReference Include="xunit">
51-
<Version>2.3.1</Version>
52-
</PackageReference>
53-
<PackageReference Include="xunit.runner.visualstudio">
54-
<Version>2.3.1</Version>
55-
</PackageReference>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
11+
<PackageReference Include="xunit" Version="2.4.0" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
13+
<PackageReference Include="FluentAssertions" Version="5.8.0" />
5614
</ItemGroup>
15+
5716
<ItemGroup>
58-
<ProjectReference Include="..\Xunit.Priority\Xunit.Priority.csproj">
59-
<Project>{48a79852-5d52-4639-9140-f3408ad728be}</Project>
60-
<Name>Xunit.Priority</Name>
61-
</ProjectReference>
17+
<ProjectReference Include="..\Xunit.Priority\Xunit.Priority.csproj" />
6218
</ItemGroup>
63-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
6419
</Project>

Xunit.Priority.sln

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27130.2003
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29123.88
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Xunit.Priority", "Xunit.Priority\Xunit.Priority.csproj", "{48A79852-5D52-4639-9140-F3408AD728BE}"
77
EndProject
@@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1111
ProjectSection(SolutionItems) = preProject
1212
LICENSE.txt = LICENSE.txt
1313
README.md = README.md
14+
version.json = version.json
1415
EndProjectSection
1516
EndProject
1617
Global

Xunit.Priority/PriorityAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2018 Aaron Sherber
2+
* Copyright 2018-2019 Aaron Sherber
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"profiles": {
3+
"Xunit.Priority": {
4+
"commandName": "Project"
5+
}
6+
}
7+
}

Xunit.Priority/Xunit.Priority.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
</PropertyGroup>
1818

1919
<ItemGroup>
20-
<PackageReference Include="Nerdbank.GitVersioning" Version="2.1.11" PrivateAssets="all" />
2120
<PackageReference Include="xunit.extensibility.core" Version="2.3.1" />
2221
</ItemGroup>
2322

0 commit comments

Comments
 (0)