mirror of
https://github.com/markjprice/cs11dotnet7.git
synced 2026-04-04 13:57:37 +00:00
Initial commit
This commit is contained in:
parent
e523533d17
commit
10cceacca6
50 changed files with 1280 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.0">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CalculatorLib\CalculatorLib.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
using CalculatorLib;
|
||||
|
||||
namespace CalculatorLibUnitTests
|
||||
{
|
||||
public class CalculatorUnitTests
|
||||
{
|
||||
[Fact]
|
||||
public void TestAdding2And2()
|
||||
{
|
||||
// arrange
|
||||
double a = 2;
|
||||
double b = 2;
|
||||
double expected = 4;
|
||||
Calculator calc = new();
|
||||
// act
|
||||
double actual = calc.Add(a, b);
|
||||
// assert
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestAdding2And3()
|
||||
{
|
||||
// arrange
|
||||
double a = 2;
|
||||
double b = 3;
|
||||
double expected = 5;
|
||||
Calculator calc = new();
|
||||
// act
|
||||
double actual = calc.Add(a, b);
|
||||
// assert
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
vs4win/Chapter04/CalculatorLibUnitTests/Usings.cs
Normal file
1
vs4win/Chapter04/CalculatorLibUnitTests/Usings.cs
Normal file
|
|
@ -0,0 +1 @@
|
|||
global using Xunit;
|
||||
Loading…
Add table
Add a link
Reference in a new issue