Basic setup of a test that runs against the actual data base.
This commit is contained in:
parent
896f31389a
commit
f13a8487be
|
@ -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/
|
||||
|
|
|
@ -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"
|
||||
]
|
||||
|
||||
|
|
@ -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>
|
Loading…
Reference in New Issue