Skip to content

Commit

Permalink
Make unit tests more robust about versions
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed May 30, 2018
1 parent 5062799 commit f9f6e45
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Build/targets.fsx
Expand Up @@ -1703,7 +1703,7 @@ _Target "ReleaseXUnitFSharpTypesDotNetFullRunner" ( fun _ ->
"System.Void Tests.DU::testMakeUnion()";
"System.Void Tests.M::testMakeThing()";
"Tests.DU/MyUnion Tests.DU/MyUnion::as_bar()";
"Tests.DU/MyUnion Tests.DU/get_MyBar@31::Invoke(Microsoft.FSharp.Core.Unit)";
"Tests.DU/MyUnion Tests.DU/get_MyBar@36::Invoke(Microsoft.FSharp.Core.Unit)";
"Tests.DU/MyUnion Tests.DU::returnBar(System.String)";
"Tests.DU/MyUnion Tests.DU::returnFoo(System.Int32)";
"Tests.M/Thing Tests.M::makeThing(System.String)"]
Expand Down Expand Up @@ -1786,7 +1786,7 @@ _Target "MSBuildTest" ( fun _ ->
"System.Void Tests.DU::testMakeUnion()";
"System.Void Tests.M::testMakeThing()";
"Tests.DU/MyUnion Tests.DU/MyUnion::as_bar()";
"Tests.DU/MyUnion Tests.DU/get_MyBar@31::Invoke(Microsoft.FSharp.Core.Unit)";
"Tests.DU/MyUnion Tests.DU/get_MyBar@36::Invoke(Microsoft.FSharp.Core.Unit)";
"Tests.DU/MyUnion Tests.DU::returnBar(System.String)";
"Tests.DU/MyUnion Tests.DU::returnFoo(System.Int32)";
"Tests.M/Thing Tests.M::makeThing(System.String)"]
Expand Down
5 changes: 5 additions & 0 deletions Sample4/Tests.fs
@@ -1,8 +1,13 @@
namespace Tests

open System
open System.Reflection
open Xunit

[<assembly: AssemblyVersionAttribute("1.0.0.0")>]
[<assembly: AssemblyFileVersionAttribute("1.0.0.0")>]
do ()

module M =
type Thing = { Thing: string } with
member this.bytes () = System.Text.Encoding.UTF8.GetBytes(this.Thing)
Expand Down
4 changes: 2 additions & 2 deletions Tests/Tests.fs
Expand Up @@ -2925,7 +2925,7 @@ type AltCoverTests() = class
use stream' = Assembly.GetExecutingAssembly().GetManifestResourceStream(resultName)
use reader' = new StreamReader(stream')
let expected = reader'.ReadToEnd()
let version = Assembly.GetExecutingAssembly().GetName().Version.ToString()
let version = System.AssemblyVersionInformation.AssemblyVersion
let transform (s:string) =
s.Replace("\r\n","\n"
).Replace("AltCover.Recorder.g/1.4.0.0", "AltCover.Recorder.g/" + version
Expand All @@ -2948,7 +2948,7 @@ type AltCoverTests() = class
use reader' = new StreamReader(stream')
let expected = reader'.ReadToEnd()

let version = Assembly.GetExecutingAssembly().GetName().Version.ToString()
let version = System.AssemblyVersionInformation.AssemblyVersion
let transform (s:string) =
s.Replace("\r\n","\n"
).Replace("AltCover.Recorder.g/2.0.0.0", "AltCover.Recorder.g/" + version
Expand Down
6 changes: 3 additions & 3 deletions XTests/XTests.fs
Expand Up @@ -193,7 +193,7 @@ module XTests =
"\n => " + Path.Combine(Path.GetFullPath input, "Sample4.dll") +
"\n\nCoverage Report: " + report +
"\n\n\n " + Path.Combine(Path.GetFullPath output, "Sample4.dll") +
"\n <= Sample4, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null\n"
"\n <= Sample4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\n"

Assert.Equal (stdout.ToString().Replace("\r\n", "\n").Replace("\\", "/"),
(expected.Replace("\\", "/")))
Expand Down Expand Up @@ -297,14 +297,14 @@ module XTests =
|> Seq.map (fun p -> p.Name)
|> Set.ofSeq
Assert.True(aux |> Set.contains ("AltCover.Recorder.g/" +
Assembly.GetExecutingAssembly().GetName().Version.ToString()))
System.AssemblyVersionInformation.AssemblyVersion))
let libraries = (o.Properties()
|> Seq.find (fun p -> p.Name = "libraries")).Value :?> JObject
let lib = libraries.Properties()
|> Seq.map (fun p -> p.Name)
|> Set.ofSeq
Assert.True(lib |> Set.contains ("AltCover.Recorder.g/" +
Assembly.GetExecutingAssembly().GetName().Version.ToString()))
System.AssemblyVersionInformation.AssemblyVersion))

[<Fact>]
let ADryRunLooksAsExpected() =
Expand Down

0 comments on commit f9f6e45

Please sign in to comment.