diff --git a/test/coverlet.core.tests/Reporters/JsonReporterTests.cs b/test/coverlet.core.tests/Reporters/JsonReporterTests.cs index b6215befe..fb4dbd616 100644 --- a/test/coverlet.core.tests/Reporters/JsonReporterTests.cs +++ b/test/coverlet.core.tests/Reporters/JsonReporterTests.cs @@ -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().Object)); - Assert.NotEqual(string.Empty, reporter.Report(result, new Mock().Object)); - } + var reporter = new JsonReporter(); + Assert.Equal(s_resultModule, reporter.Report(result, new Mock().Object)); } -} \ No newline at end of file + } +}