Basic setup of a test that runs against the actual data base.

This commit is contained in:
Achim D. Brucker 2018-07-20 08:28:46 +01:00
parent 896f31389a
commit f13a8487be
3 changed files with 47 additions and 2 deletions

1
.gitignore vendored
View File

@ -193,6 +193,7 @@ docs
# ignore app.config
src/LogicalHacking.ExtensionDsLab/app.config
tests/LogicalHacking.ExtensionDsLab.Tests/app.config
# ignore superfluous directories created by FSLab
*/*/DesignTimeURIs/

View File

@ -4,15 +4,38 @@ open Expecto
open FsCheck
open GeneratorsCode
open System
open System.Configuration
open LogicalHacking.ExtensionDsLab
open LogicalHacking.ExtensionDsLab.Archive.MySqlConnector
open LogicalHacking.ExtensionDsLab.Archive.ExtensionCore
module Tests =
let config10k = { FsCheckConfig.defaultConfig with maxTest = 10000}
// bug somewhere: registering arbitrary generators causes Expecto VS test adapter not to work
//let config10k = { FsCheckConfig.defaultConfig with maxTest = 10000; arbitrary = [typeof<Generators>] }
let configReplay = { FsCheckConfig.defaultConfig with maxTest = 10000 ; replay = Some <| (1940624926, 296296394) }
let connectionStringOrDefault defaultString =
let map = new ExeConfigurationFileMap(ExeConfigFilename = __SOURCE_DIRECTORY__ + "/app.config")
let config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None)
match config.ConnectionStrings.ConnectionStrings.["ProductionExtensionDB"] with
| null -> defaultString
| a -> a.ConnectionString
let ctx = ExtensionDbProvider.GetDataContext(connectionStringOrDefault "")
let measureExecutionTime f =
let timer = new System.Diagnostics.Stopwatch()
timer.Start()
let result = f()
(int32(timer.ElapsedMilliseconds), result)
[<Tests>]
let testSimpleTests =
testList "DomainTypes.Tag" [
testCase "equality" <| fun () ->
let result = 42
@ -23,5 +46,9 @@ module Tests =
Prop.forAll (Arb.fromGen <| whitespaceString())
(fun (x : string) ->
x = x)
testCase "Testing Performance of getDownloads" <| fun () ->
let (time, result) = measureExecutionTime (fun () -> (getDownloads ctx "lkllajgbhondgjjnhmmgbjndmogapinp"))
Expect.isLessThan time 1500 "Query should take less than 1500ms"
]

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="ProductionExtensionDB" providerName="FSharp.Data.Sql.SqlTypeProvider"
connectionString="Server=<SERVER>;Database=extensions;User=<LOGIN>;Password=<PWD>"/>
</connectionStrings>
<runtime>
<assemblyBinding
xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.4.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>