Skip to content

Commit

Permalink
More unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveGilham committed Dec 20, 2019
1 parent 5a9dc4e commit 88d871f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Tests/Program.fs
Expand Up @@ -151,6 +151,8 @@ module TestMain =
Tests.AltCoverTests.CanIdentifyExcludedCSharpAutoProperties, "Tests.CanIdentifyExcludedCSharpAutoProperties"
Tests.AltCoverTests.CanIdentifyIncludedCSharpProperties, "Tests.CanIdentifyIncludedCSharpProperties"
Tests.AltCoverTests.FixEnding, "Tests.FixEnding"
Tests.AltCoverTests.ValidateStaticExemption, "Tests.ValidateStaticExemption"
Tests.AltCoverTests.ValidateAutomaticExemption, "Tests.ValidateAutomaticExemption"
Tests.AltCoverTests.DetectLocalSource, "Tests.DetectLocalSource"
Tests.AltCoverTests.LocateMatchShouldChooseLongerWildCardPath, "Tests.LocateMatchShouldChooseLongerWildCardPath"
Tests.AltCoverTests.ReleaseBuildTernaryTest, "Tests.ReleaseBuildTernaryTest"
Expand Down
38 changes: 37 additions & 1 deletion Tests/Tests.fs
Expand Up @@ -14,6 +14,7 @@ open Mono.Cecil
open Mono.Cecil.Cil
open Mono.Cecil.Rocks
open N
open Swensen.Unquote

[<NUnit.Framework.IncludeExcludeAttribute>]
type ProxyObject() =
Expand Down Expand Up @@ -792,6 +793,42 @@ module AltCoverTests =
let s = Visitor.EnsureEndsWith "s" "banana"
Assert.That (s, Is.EqualTo "bananas")

[<Test>]
let ValidateStaticExemption() =
let result =
[
StaticFilter.AsCovered
StaticFilter.Hidden
StaticFilter.NoFilter
]
|> List.map (fun k -> Visitor.SelectExemption k [] Exemption.None)
test <@ result = [ Exemption.StaticAnalysis; Exemption.None; Exemption.None ] @>

[<Test>]
let ValidateAutomaticExemption() =
try
Visitor.showGenerated := true
let where = Assembly.GetExecutingAssembly().Location
let path =
Path.Combine(Path.GetDirectoryName(where) + Hack(), "Sample4.dll")
use def = Mono.Cecil.AssemblyDefinition.ReadAssembly path
let items =
def.MainModule.GetAllTypes()
|> Seq.collect (fun t -> t.Methods)
|> Seq.filter (fun m -> m.Name = "testMakeUnion")
|> Seq.toList

let result =
[
StaticFilter.AsCovered
StaticFilter.Hidden
StaticFilter.NoFilter
]
|> List.map (fun k -> Visitor.SelectExemption k items Exemption.None)
test <@ result = [ Exemption.StaticAnalysis; Exemption.Automatic; Exemption.Automatic ] @>
finally
Visitor.showGenerated := false

[<Test>]
let DetectLocalSource() =

Expand Down Expand Up @@ -1658,7 +1695,6 @@ module AltCoverTests =
let AssembliesAreDeeperThanPaths() =
try
Visitor.staticFilter <- Some StaticFilter.AsCovered

let where = Assembly.GetExecutingAssembly().Location
let path =
Path.Combine(Path.GetDirectoryName(where) + Hack(), sample1)
Expand Down

0 comments on commit 88d871f

Please sign in to comment.