Skip to content

Commit

Permalink
FileConventions: add failing test
Browse files Browse the repository at this point in the history
Add tests for async project, Async.RunSynchronously only
allowed in console applications.
  • Loading branch information
Mersho committed Aug 22, 2023
1 parent f013203 commit a0a8e5a
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

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

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
async {
do! Async.Sleep(5000)
} |> Async.RunSynchronously
printf "Hello World"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

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

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace DummyProjectAsync

module Say =

let delayedHello name =
async {
do! Async.Sleep(5000)
} |> Async.RunSynchronously
"Delayed Hello"
28 changes: 28 additions & 0 deletions src/FileConventions.Test/FileConventions.Test.fs
Original file line number Diff line number Diff line change
Expand Up @@ -803,3 +803,31 @@ let ConsoleAppConvention4() =
)

Assert.That(NotFollowingConsoleAppConvention fileInfo, Is.EqualTo false)


[<Test>]
let ConsoleAppConvention5() =
let fileInfo =
FileInfo(
Path.Combine(
dummyFilesDirectory.FullName,
"DummyProjectAsync",
"DummyProjectAsync.fsproj"
)
)

Assert.That(NotFollowingConsoleAppConvention fileInfo, Is.EqualTo true)


[<Test>]
let ConsoleAppConvention6() =
let fileInfo =
FileInfo(
Path.Combine(
dummyFilesDirectory.FullName,
"DummyProjectAsync.Console",
"DummyProjectAsync.Console.fsproj"
)
)

Assert.That(NotFollowingConsoleAppConvention fileInfo, Is.EqualTo false)

0 comments on commit a0a8e5a

Please sign in to comment.