-
Notifications
You must be signed in to change notification settings - Fork 387
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
41 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,57 @@ | ||
// Copyright (c) Toni Solarin-Sodara | ||
// Copyright (c) Toni Solarin-Sodara | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using Coverlet.Core.Abstractions; | ||
using Moq; | ||
using System; | ||
using Xunit; | ||
|
||
namespace Coverlet.Core.Reporters.Tests | ||
{ | ||
public class JsonReporterTests | ||
public class JsonReporterTests | ||
{ | ||
private static readonly string s_resultModule = @"{ | ||
""module"": { | ||
""doc.cs"": { | ||
""Coverlet.Core.Reporters.Tests.JsonReporterTests"": { | ||
""System.Void Coverlet.Core.Reporters.Tests.JsonReporterTests.TestReport()"": { | ||
""Lines"": { | ||
""1"": 1, | ||
""2"": 0 | ||
}, | ||
""Branches"": [] | ||
} | ||
} | ||
} | ||
} | ||
}"; | ||
|
||
[Fact] | ||
public void TestReport() | ||
{ | ||
[Fact] | ||
public void TestReport() | ||
{ | ||
var result = new CoverageResult(); | ||
result.Identifier = Guid.NewGuid().ToString(); | ||
var result = new CoverageResult(); | ||
result.Identifier = Guid.NewGuid().ToString(); | ||
|
||
var lines = new Lines(); | ||
lines.Add(1, 1); | ||
lines.Add(2, 0); | ||
var lines = new Lines(); | ||
lines.Add(1, 1); | ||
lines.Add(2, 0); | ||
|
||
var methods = new Methods(); | ||
string methodString = "System.Void Coverlet.Core.Reporters.Tests.JsonReporterTests.TestReport()"; | ||
methods.Add(methodString, new Method()); | ||
methods[methodString].Lines = lines; | ||
var methods = new Methods(); | ||
string methodString = "System.Void Coverlet.Core.Reporters.Tests.JsonReporterTests.TestReport()"; | ||
methods.Add(methodString, new Method()); | ||
methods[methodString].Lines = lines; | ||
|
||
var classes = new Classes(); | ||
classes.Add("Coverlet.Core.Reporters.Tests.JsonReporterTests", methods); | ||
var classes = new Classes(); | ||
classes.Add("Coverlet.Core.Reporters.Tests.JsonReporterTests", methods); | ||
|
||
var documents = new Documents(); | ||
documents.Add("doc.cs", classes); | ||
var documents = new Documents(); | ||
documents.Add("doc.cs", classes); | ||
|
||
result.Modules = new Modules(); | ||
result.Modules.Add("module", documents); | ||
result.Modules = new Modules(); | ||
result.Modules.Add("module", documents); | ||
|
||
var reporter = new JsonReporter(); | ||
Assert.NotEqual("{\n}", reporter.Report(result, new Mock<ISourceRootTranslator>().Object)); | ||
Assert.NotEqual(string.Empty, reporter.Report(result, new Mock<ISourceRootTranslator>().Object)); | ||
} | ||
var reporter = new JsonReporter(); | ||
Assert.Equal(s_resultModule, reporter.Report(result, new Mock<ISourceRootTranslator>().Object)); | ||
} | ||
} | ||
} | ||
} |