Last active
November 3, 2022 07:56
-
-
Save thomaslevesque/372b8cff3661c3be1d3fb5181ce5d89c to your computer and use it in GitHub Desktop.
Tests in same project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bin/ | |
obj/ | |
.vs/ | |
.idea/ | |
.vscode/ | |
*.user | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace TestsInSameProject; | |
class Calculator | |
{ | |
public int Add(int x, int y) => x + y; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Xunit; | |
namespace TestsInSameProject; | |
public class CalculatorTests | |
{ | |
[Theory] | |
[InlineData(1, 2, 3)] | |
[InlineData(1, 0, 1)] | |
[InlineData(0, 0, 0)] | |
[InlineData(1, -2, -1)] | |
public void Add_Returns_Sum_Of_Arguments(int x, int y, int expected) | |
{ | |
var calculator = new Calculator(); | |
var actual = calculator.Add(x, y); | |
Assert.Equal(expected, actual); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"sdk": { | |
"version": "6.0.402" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using TestsInSameProject; | |
if (args.Length < 2) | |
{ | |
Console.Error.WriteLine("Missing arguments"); | |
return 1; | |
} | |
int x = int.Parse(args[0]); | |
int y = int.Parse(args[1]); | |
var calculator = new Calculator(); | |
int result = calculator.Add(x, y); | |
Console.WriteLine(result); | |
return 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>net6.0</TargetFramework> | |
<ImplicitUsings>enable</ImplicitUsings> | |
<Nullable>enable</Nullable> | |
</PropertyGroup> | |
<ItemGroup Condition="$(StripTests) != 'true'"> | |
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> | |
<PackageReference Include="xunit" Version="2.4.2" /> | |
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | |
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | |
<PrivateAssets>all</PrivateAssets> | |
</PackageReference> | |
</ItemGroup> | |
<ItemGroup Condition="$(StripTests) == 'true'"> | |
<Compile Remove="**/*Tests.cs" /> | |
</ItemGroup> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment