@@ -92,5 +92,43 @@ public void TestCoverageWithTestAssembly()
9292
9393 directory . Delete ( true ) ;
9494 }
95+
96+ [ Fact ]
97+ public void TestCoverageWrongMergeWith ( )
98+ {
99+ string module = GetType ( ) . Assembly . Location ;
100+ string pdb = Path . Combine ( Path . GetDirectoryName ( module ) , Path . GetFileNameWithoutExtension ( module ) + ".pdb" ) ;
101+
102+ DirectoryInfo directory = Directory . CreateDirectory ( Path . Combine ( Path . GetTempPath ( ) , Guid . NewGuid ( ) . ToString ( ) ) ) ;
103+
104+ File . Copy ( module , Path . Combine ( directory . FullName , Path . GetFileName ( module ) ) , true ) ;
105+ File . Copy ( pdb , Path . Combine ( directory . FullName , Path . GetFileName ( pdb ) ) , true ) ;
106+
107+ // TODO: Find a way to mimick hits
108+ var instrumentationHelper =
109+ new InstrumentationHelper ( new ProcessExitHandler ( ) , new RetryHelper ( ) , new FileSystem ( ) , new Mock < ILogger > ( ) . Object ,
110+ new SourceRootTranslator ( module , new Mock < ILogger > ( ) . Object , new FileSystem ( ) , new AssemblyAdapter ( ) ) ) ;
111+
112+ var parameters = new CoverageParameters
113+ {
114+ IncludeFilters = new string [ ] { "[coverlet.tests.projectsample.excludedbyattribute*]*" } ,
115+ IncludeDirectories = Array . Empty < string > ( ) ,
116+ ExcludeFilters = Array . Empty < string > ( ) ,
117+ ExcludedSourceFiles = Array . Empty < string > ( ) ,
118+ ExcludeAttributes = Array . Empty < string > ( ) ,
119+ IncludeTestAssembly = false ,
120+ SingleHit = false ,
121+ MergeWith = "blabla" ,
122+ UseSourceLink = false
123+ } ;
124+
125+ var coverage = new Coverage ( Path . Combine ( directory . FullName , Path . GetFileName ( module ) ) , parameters , _mockLogger . Object , instrumentationHelper , new FileSystem ( ) , new SourceRootTranslator ( _mockLogger . Object , new FileSystem ( ) ) , new CecilSymbolHelper ( ) ) ;
126+ coverage . PrepareModules ( ) ;
127+
128+ ArgumentException exception = Assert . Throws < ArgumentException > ( ( ) => coverage . GetCoverageResult ( ) ) ;
129+ Assert . Contains ( "blabla" , exception . Message ) ;
130+
131+ directory . Delete ( true ) ;
132+ }
95133 }
96134}
0 commit comments