Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Workflow/Workflow.Test/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Program =

[<EntryPoint>]
let main _ = 0
27 changes: 27 additions & 0 deletions Workflow/Workflow.Test/Workflow.Test.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>

<ItemGroup>
<Compile Include="WorkflowTest.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FsUnit" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
<PackageReference Include="coverlet.collector" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Workflow\Workflow.fsproj" />
</ItemGroup>

</Project>
50 changes: 50 additions & 0 deletions Workflow/Workflow.Test/WorkflowTest.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module Workflow.Test

open System
open NUnit.Framework
open FsUnit
open Workflows

[<Test>]
let RoundTest () =

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не хватает теста на отрицательное значение округления

let rounding i = new RoundBuilder(i)
let result =
rounding 3 {
let! a = 2.0 / 12.0
let! b = 3.5
return a / b
}
result |> should equal 0.048

[<Test>]
let RoundWithTest () =
(fun () ->
RoundBuilder.rounding -3 {
let! a = 2.0 / 12.0
let! b = 3.5
return a / b
} |> ignore) |> should throw typeof<System.ArgumentOutOfRangeException>

[<Test>]
let CalculateTest () =
let calculate = new CalculateBuilder()
let result =
calculate {
let! a = "1"
let! b = "3"
let z = a + b
return z
}
result |> should equal (Some 4)

[<Test>]
let CalculateTestIncorrect () =
let calculate = new CalculateBuilder()
let result =
calculate {
let! a = "1"
let! b = "."
let z = a + b
return z
}
result |> should equal None
22 changes: 22 additions & 0 deletions Workflow/Workflow.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Workflow", "Workflow\Workflow.fsproj", "{A6036D48-D2F8-46B8-9DEE-AB17878E8806}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Workflow.Test", "Workflow.Test\Workflow.Test.fsproj", "{92E2C706-313D-4973-B32E-5BE88E2980CB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A6036D48-D2F8-46B8-9DEE-AB17878E8806}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A6036D48-D2F8-46B8-9DEE-AB17878E8806}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A6036D48-D2F8-46B8-9DEE-AB17878E8806}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A6036D48-D2F8-46B8-9DEE-AB17878E8806}.Release|Any CPU.Build.0 = Release|Any CPU
{92E2C706-313D-4973-B32E-5BE88E2980CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{92E2C706-313D-4973-B32E-5BE88E2980CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92E2C706-313D-4973-B32E-5BE88E2980CB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92E2C706-313D-4973-B32E-5BE88E2980CB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions Workflow/Workflow/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module Workflows
open System

type RoundBuilder(i : int) =
static member rounding = RoundBuilder
member this.Bind(x: float, f) = f (Math.Round(x, i))
member this.Return(x: float) = Math.Round(x, i)

type CalculateBuilder() =
member this.Bind(x : string, f) =
match Int32.TryParse x with
| true, x -> f x
| false, _ -> None
member this.Return(x) = Some x
13 changes: 13 additions & 0 deletions Workflow/Workflow/Workflow.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

</Project>