Skip to content

Commit

Permalink
(#102) TestFramework: extract the code from TestUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Aug 20, 2022
1 parent 4966c7e commit 37fed71
Show file tree
Hide file tree
Showing 22 changed files with 53 additions and 31 deletions.
23 changes: 23 additions & 0 deletions Emulsion.TestFramework/Emulsion.TestFramework.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

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

<ItemGroup>
<Compile Include="LockedBuffer.fs" />
<Compile Include="Logging.fs" />
<Compile Include="Waiter.fs" />
<Compile Include="TestDataStorage.fs" />
<Compile Include="Exceptions.fs" />
<Compile Include="TelegramClientMock.fs" />
<Compile Include="WebFileStorage.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Serilog.Sinks.XUnit" Version="1.0.8" />
<ProjectReference Include="..\Emulsion.Database\Emulsion.Database.fsproj" />
<ProjectReference Include="..\Emulsion.Telegram\Emulsion.Telegram.fsproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Emulsion.Tests.TestUtils.Exceptions
module Emulsion.TestFramework.Exceptions

open System
open Microsoft.EntityFrameworkCore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Emulsion.Tests.TestUtils
namespace Emulsion.TestFramework

type LockedBuffer<'T>() =
let messages = ResizeArray<'T>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Emulsion.Tests.TestUtils.Logging
module Emulsion.TestFramework.Logging

open Serilog
open Xunit.Abstractions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Emulsion.Tests.TestUtils
namespace Emulsion.TestFramework

open System.Collections.Generic

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Emulsion.Tests.TestUtils.TestDataStorage
module Emulsion.TestFramework.TestDataStorage

open System.IO

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Emulsion.Tests.TestUtils.Waiter
module Emulsion.TestFramework.Waiter

open System
open System.Threading
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Emulsion.Tests.TestUtils
namespace Emulsion.TestFramework

open System

Expand Down
2 changes: 1 addition & 1 deletion Emulsion.Tests/Actors/Core.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ open Xunit.Abstractions
open Emulsion
open Emulsion.Actors
open Emulsion.Messaging
open Emulsion.Tests.TestUtils
open Emulsion.TestFramework

type CoreTests(testOutput: ITestOutputHelper) as this =
inherit TestKit()
Expand Down
2 changes: 1 addition & 1 deletion Emulsion.Tests/Actors/Telegram.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ open Emulsion
open Emulsion.Actors
open Emulsion.Messaging
open Emulsion.Messaging.MessageSystem
open Emulsion.Tests.TestUtils
open Emulsion.TestFramework

type TelegramTest(testOutput: ITestOutputHelper) =
inherit TestKit()
Expand Down
2 changes: 1 addition & 1 deletion Emulsion.Tests/Actors/Xmpp.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ open Emulsion
open Emulsion.Actors
open Emulsion.Messaging
open Emulsion.Messaging.MessageSystem
open Emulsion.Tests.TestUtils
open Emulsion.TestFramework

type XmppTest(testOutput: ITestOutputHelper) =
inherit TestKit()
Expand Down
2 changes: 1 addition & 1 deletion Emulsion.Tests/ContentProxy/ContentStorageTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ open Xunit

open Emulsion.ContentProxy.ContentStorage
open Emulsion.Database
open Emulsion.Tests.TestUtils
open Emulsion.TestFramework

let private testIdentity = {
ChatUserName = "test"
Expand Down
4 changes: 2 additions & 2 deletions Emulsion.Tests/ContentProxy/FileCacheTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ open Xunit.Abstractions

open Emulsion.ContentProxy
open Emulsion.Settings
open Emulsion.Tests.TestUtils
open Emulsion.Tests.TestUtils.Logging
open Emulsion.TestFramework
open Emulsion.TestFramework.Logging

type FileCacheTests(outputHelper: ITestOutputHelper) =

Expand Down
2 changes: 1 addition & 1 deletion Emulsion.Tests/Database/DatabaseStructureTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ open Xunit

open Emulsion.Database
open Emulsion.Database.Entities
open Emulsion.Tests.TestUtils
open Emulsion.TestFramework

[<Fact>]
let ``Unique constraint should hold``(): unit =
Expand Down
9 changes: 1 addition & 8 deletions Emulsion.Tests/Emulsion.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<Compile Include="TestUtils\LockedBuffer.fs" />
<Compile Include="TestUtils\Logging.fs" />
<Compile Include="TestUtils\Waiter.fs" />
<Compile Include="TestUtils\TestDataStorage.fs" />
<Compile Include="TestUtils\Exceptions.fs" />
<Compile Include="TestUtils\TelegramClientMock.fs" />
<Compile Include="TestUtils\WebFileStorage.fs" />
<Compile Include="ExceptionUtilsTests.fs" />
<Compile Include="LifetimesTests.fs" />
<Compile Include="MessageSenderTests.fs" />
Expand Down Expand Up @@ -42,10 +35,10 @@
<PackageReference Include="Akka.TestKit.Xunit2" Version="1.3.12" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="Serilog.Sinks.TestCorrelator" Version="3.2.0" />
<PackageReference Include="Serilog.Sinks.XUnit" Version="1.0.8" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<ProjectReference Include="../Emulsion/Emulsion.fsproj" />
<ProjectReference Include="..\Emulsion.Database\Emulsion.Database.fsproj" />
<ProjectReference Include="..\Emulsion.TestFramework\Emulsion.TestFramework.fsproj" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions Emulsion.Tests/MessageSenderTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ open Xunit.Abstractions

open Emulsion.Messaging
open Emulsion.Messaging.MessageSender
open Emulsion.Tests.TestUtils
open Emulsion.Tests.TestUtils.Waiter
open Emulsion.TestFramework
open Emulsion.TestFramework.Waiter

type MessageSenderTests(testOutput: ITestOutputHelper) =
let testContext = {
Expand Down
4 changes: 2 additions & 2 deletions Emulsion.Tests/MessageSystemTests/MessageSystemBaseTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ open Xunit.Abstractions
open Emulsion
open Emulsion.Messaging
open Emulsion.Messaging.MessageSystem
open Emulsion.Tests.TestUtils
open Emulsion.Tests.TestUtils.Waiter
open Emulsion.TestFramework
open Emulsion.TestFramework.Waiter

type MessageSystemBaseTests(testLogger: ITestOutputHelper) =
let logger = Logging.xunitLogger testLogger
Expand Down
2 changes: 1 addition & 1 deletion Emulsion.Tests/Telegram/LinkGeneratorTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ open Xunit
open Emulsion.Database
open Emulsion.Settings
open Emulsion.Telegram
open Emulsion.Tests.TestUtils
open Emulsion.TestFramework

let private hostingSettings = {
ExternalUriBase = Uri "https://example.com"
Expand Down
4 changes: 2 additions & 2 deletions Emulsion.Tests/Web/ContentControllerTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ open Emulsion.Database
open Emulsion.Database.Entities
open Emulsion.Settings
open Emulsion.Telegram
open Emulsion.Tests.TestUtils
open Emulsion.Tests.TestUtils.Logging
open Emulsion.TestFramework
open Emulsion.TestFramework.Logging
open Emulsion.Web

type ContentControllerTests(output: ITestOutputHelper) =
Expand Down
2 changes: 1 addition & 1 deletion Emulsion.Tests/Xmpp/EmulsionXmppTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ open Xunit.Abstractions
open Emulsion
open Emulsion.Messaging
open Emulsion.Settings
open Emulsion.Tests.TestUtils
open Emulsion.TestFramework
open Emulsion.Tests.Xmpp
open Emulsion.Xmpp
open Emulsion.Xmpp.SharpXmppHelper.Elements
Expand Down
2 changes: 1 addition & 1 deletion Emulsion.Tests/Xmpp/XmppClientRoomTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ open Emulsion
open Emulsion.Xmpp
open Emulsion.Xmpp.SharpXmppHelper.Attributes
open Emulsion.Xmpp.SharpXmppHelper.Elements
open Emulsion.Tests.TestUtils.Logging
open Emulsion.TestFramework.Logging

type XmppClientRoomTests(output: ITestOutputHelper) =
let logger = xunitLogger output
Expand Down
6 changes: 6 additions & 0 deletions Emulsion.sln
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Emulsion.Telegram", "Emulsi
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Emulsion.Messaging", "Emulsion.Messaging\Emulsion.Messaging.fsproj", "{C8DC4049-250B-4E84-BC98-CFC0AF1632AF}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Emulsion.TestFramework", "Emulsion.TestFramework\Emulsion.TestFramework.fsproj", "{381D687B-6520-48F1-8AA0-3EDB45654AAC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -89,6 +91,10 @@ Global
{C8DC4049-250B-4E84-BC98-CFC0AF1632AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8DC4049-250B-4E84-BC98-CFC0AF1632AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8DC4049-250B-4E84-BC98-CFC0AF1632AF}.Release|Any CPU.Build.0 = Release|Any CPU
{381D687B-6520-48F1-8AA0-3EDB45654AAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{381D687B-6520-48F1-8AA0-3EDB45654AAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{381D687B-6520-48F1-8AA0-3EDB45654AAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{381D687B-6520-48F1-8AA0-3EDB45654AAC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{7D1ADF47-BF1C-4007-BB9B-08C283044467} = {973131E1-E645-4A50-A0D2-1886A1A8F0C6}
Expand Down

0 comments on commit 37fed71

Please sign in to comment.