1- // Copyright (c) Toni Solarin-Sodara
1+ // Copyright (c) Toni Solarin-Sodara
22// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33
4+ using System ;
45using Coverlet . Core . Abstractions ;
56using Moq ;
6- using System ;
77using Xunit ;
88
99namespace Coverlet . Core . Reporters . Tests
1010{
11- public class JsonReporterTests
11+ public class JsonReporterTests
12+ {
13+ private static readonly string resultModule = @"{
14+ ""module"": {
15+ ""doc.cs"": {
16+ ""Coverlet.Core.Reporters.Tests.JsonReporterTests"": {
17+ ""System.Void Coverlet.Core.Reporters.Tests.JsonReporterTests.TestReport()"": {
18+ ""Lines"": {
19+ ""1"": 1,
20+ ""2"": 0
21+ },
22+ ""Branches"": []
23+ }
24+ }
25+ }
26+ }
27+ }" ;
28+
29+ [ Fact ]
30+ public void TestReport ( )
1231 {
13- [ Fact ]
14- public void TestReport ( )
15- {
16- var result = new CoverageResult ( ) ;
17- result . Identifier = Guid . NewGuid ( ) . ToString ( ) ;
32+ var result = new CoverageResult ( ) ;
33+ result . Identifier = Guid . NewGuid ( ) . ToString ( ) ;
1834
19- var lines = new Lines ( ) ;
20- lines . Add ( 1 , 1 ) ;
21- lines . Add ( 2 , 0 ) ;
35+ var lines = new Lines ( ) ;
36+ lines . Add ( 1 , 1 ) ;
37+ lines . Add ( 2 , 0 ) ;
2238
23- var methods = new Methods ( ) ;
24- string methodString = "System.Void Coverlet.Core.Reporters.Tests.JsonReporterTests.TestReport()" ;
25- methods . Add ( methodString , new Method ( ) ) ;
26- methods [ methodString ] . Lines = lines ;
39+ var methods = new Methods ( ) ;
40+ string methodString = "System.Void Coverlet.Core.Reporters.Tests.JsonReporterTests.TestReport()" ;
41+ methods . Add ( methodString , new Method ( ) ) ;
42+ methods [ methodString ] . Lines = lines ;
2743
28- var classes = new Classes ( ) ;
29- classes . Add ( "Coverlet.Core.Reporters.Tests.JsonReporterTests" , methods ) ;
44+ var classes = new Classes ( ) ;
45+ classes . Add ( "Coverlet.Core.Reporters.Tests.JsonReporterTests" , methods ) ;
3046
31- var documents = new Documents ( ) ;
32- documents . Add ( "doc.cs" , classes ) ;
47+ var documents = new Documents ( ) ;
48+ documents . Add ( "doc.cs" , classes ) ;
3349
34- result . Modules = new Modules ( ) ;
35- result . Modules . Add ( "module" , documents ) ;
50+ result . Modules = new Modules ( ) ;
51+ result . Modules . Add ( "module" , documents ) ;
3652
37- var reporter = new JsonReporter ( ) ;
38- Assert . NotEqual ( "{\n }" , reporter . Report ( result , new Mock < ISourceRootTranslator > ( ) . Object ) ) ;
39- Assert . NotEqual ( string . Empty , reporter . Report ( result , new Mock < ISourceRootTranslator > ( ) . Object ) ) ;
40- }
53+ var reporter = new JsonReporter ( ) ;
54+ Assert . Equal ( resultModule , reporter . Report ( result , new Mock < ISourceRootTranslator > ( ) . Object ) ) ;
4155 }
42- }
56+ }
57+ }
0 commit comments