Move up Example.Tests a level
This commit is contained in:
parent
07cdb478a2
commit
28ae18b480
4 changed files with 3 additions and 3 deletions
10
Example.Tests/Calculator.fs
Normal file
10
Example.Tests/Calculator.fs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
namespace Example
|
||||
|
||||
module Calculator =
|
||||
let addOne value = value + 1
|
||||
|
||||
let absoluteDifference left right =
|
||||
if left >= right then left - right else right - left
|
||||
|
||||
let isLeapYear year =
|
||||
year % 4 = 0 && (year % 100 <> 0 || year % 400 = 0)
|
||||
22
Example.Tests/CalculatorTests.fs
Normal file
22
Example.Tests/CalculatorTests.fs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
namespace Example.Tests
|
||||
|
||||
open Example
|
||||
open Mutannot
|
||||
open Xunit
|
||||
|
||||
type CalculatorTests() =
|
||||
[<Fact>]
|
||||
[<MutationCase("calc-add-one", "Example.Tests/Calculator.fs", 4, "value + 1", "value - 1")>]
|
||||
member _.AddOne_increments() =
|
||||
Assert.Equal(42, Calculator.addOne 41)
|
||||
|
||||
[<Fact>]
|
||||
[<MutationCase("calc-abs-diff-branch", "Example.Tests/Calculator.fs", 7, "left - right", "right - left")>]
|
||||
member _.AbsoluteDifference_preserves_order() =
|
||||
Assert.Equal(7, Calculator.absoluteDifference 10 3)
|
||||
|
||||
[<Fact>]
|
||||
[<MutationCase("calc-leap-year-century", "Example.Tests/Calculator.fs", 10, "year % 100 <> 0", "year % 100 = 0")>]
|
||||
member _.LeapYear_handles_centuries() =
|
||||
Assert.True(Calculator.isLeapYear 2000)
|
||||
Assert.False(Calculator.isLeapYear 1900)
|
||||
21
Example.Tests/Example.Tests.fsproj
Normal file
21
Example.Tests/Example.Tests.fsproj
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="MutationCaseAttribute.fs" />
|
||||
<Compile Include="Calculator.fs" />
|
||||
<Compile Include="CalculatorTests.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
13
Example.Tests/MutationCaseAttribute.fs
Normal file
13
Example.Tests/MutationCaseAttribute.fs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
namespace Mutannot
|
||||
|
||||
open System
|
||||
|
||||
[<AttributeUsage(AttributeTargets.Method, AllowMultiple = true)>]
|
||||
type MutationCaseAttribute(id: string, file: string, line: int, find: string, replace: string) =
|
||||
inherit Attribute()
|
||||
|
||||
member _.Id = id
|
||||
member _.File = file
|
||||
member _.Line = line
|
||||
member _.Find = find
|
||||
member _.Replace = replace
|
||||
Loading…
Add table
Add a link
Reference in a new issue