From 4a7f9a9f15d178cb880bbdd1286e5125efd459b1 Mon Sep 17 00:00:00 2001 From: SimonCropp Date: Sun, 29 Mar 2020 09:28:06 +1100 Subject: [PATCH 1/6] move to verify --- .../Api/ApiApprovalTests.cs | 34 +++++++++---------- ....Api.ApiApprovalTests.Aliases.verified.cs} | 2 +- ...sts.Api.ApiApprovalTests.Core.verified.cs} | 11 +++--- ....Api.ApiApprovalTests.Testing.verified.cs} | 2 +- .../DiffPlexReporter.cs | 19 ++++------- .../Tests.System.Reactive.ApiApprovals.csproj | 13 +++---- 6 files changed, 34 insertions(+), 47 deletions(-) rename Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/{ApiApprovalTests.Aliases.approved.cs => Tests.Api.ApiApprovalTests.Aliases.verified.cs} (99%) rename Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/{ApiApprovalTests.Core.approved.cs => Tests.Api.ApiApprovalTests.Core.verified.cs} (99%) rename Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/{ApiApprovalTests.Testing.approved.cs => Tests.Api.ApiApprovalTests.Testing.verified.cs} (99%) diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.cs b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.cs index 218f8988db..4f66a6860f 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.cs @@ -2,49 +2,49 @@ // The .NET Foundation licenses this file to you under the MIT License. // See the LICENSE file in the project root for more information. -using ApprovalTests; -using ApprovalTests.Reporters; using PublicApiGenerator; using System; using System.Linq; using System.Reflection; +using System.Threading.Tasks; +using Verify; +using VerifyXunit; using Xunit; using Xunit.Abstractions; namespace ReactiveTests.Tests.Api { -#if DEBUG - [UseReporter(typeof(DiffReporter))] -#else - [UseReporter(typeof(DiffPlexReporter))] -#endif - [IgnoreLineEndings(true)] - public class ApiApprovalTests + public class ApiApprovalTests : + VerifyBase { - public ApiApprovalTests(ITestOutputHelper output) + private VerifySettings verifySettings; + + public ApiApprovalTests(ITestOutputHelper output) : + base(output) { - DiffPlexReporter.INSTANCE.Output = output; + verifySettings = new VerifySettings(); + verifySettings.UseExtension("cs"); } [Fact] - public void Core() + public Task Core() { var publicApi = GeneratePublicApi(typeof(System.Reactive.Unit).Assembly); - Approvals.Verify(new ApprovalTextWriter(publicApi, "cs")); + return Verify(publicApi, verifySettings); } [Fact] - public void Aliases() + public Task Aliases() { var publicApi = GeneratePublicApi(typeof(System.Reactive.Observable.Aliases.QueryLanguage).Assembly); - Approvals.Verify(new ApprovalTextWriter(publicApi, "cs")); + return Verify(publicApi, verifySettings); } [Fact] - public void Testing() + public Task Testing() { var publicApi = GeneratePublicApi(typeof(Microsoft.Reactive.Testing.TestScheduler).Assembly); - Approvals.Verify(new ApprovalTextWriter(publicApi, "cs")); + return Verify(publicApi, verifySettings); } private string GeneratePublicApi(Assembly assembly) diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Aliases.approved.cs b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Aliases.verified.cs similarity index 99% rename from Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Aliases.approved.cs rename to Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Aliases.verified.cs index fa3adafe6b..dd4e99449a 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Aliases.approved.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Aliases.verified.cs @@ -1,4 +1,4 @@ -[assembly: System.CLSCompliant(true)] +[assembly: System.CLSCompliant(true)] [assembly: System.Resources.NeutralResourcesLanguage("en-US")] [assembly: System.Runtime.InteropServices.ComVisible(false)] [assembly: System.Runtime.Versioning.TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName=".NET Framework 4.6")] diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.approved.cs b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Core.verified.cs similarity index 99% rename from Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.approved.cs rename to Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Core.verified.cs index c8750add6a..602878ba39 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.approved.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Core.verified.cs @@ -1,4 +1,4 @@ -[assembly: System.CLSCompliant(true)] +[assembly: System.CLSCompliant(true)] [assembly: System.Resources.NeutralResourcesLanguage("en-US")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Tests.System.Reactive, PublicKey=00240000048000009400000006020000002400005253413100040000010001008f5cff058631087031f8350f30a36fa078027e5df2316b564352dc9eb7af7ce856016d3c5e9d058036fe73bb5c83987bd3fc0793fbe25d633cc4f37c2bd5f1d717cd2a81661bec08f0971dc6078e17bde372b89005e7738a0ebd501b896ca3e8315270ff64df7809dd912c372df61785a5085b3553b7872e39b1b1cc0ff5a6bc")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Tests.System.Reactive.Uwp.DeviceRunner, PublicKey=00240000048000009400000006020000002400005253413100040000010001008f5cff058631087031f8350f30a36fa078027e5df2316b564352dc9eb7af7ce856016d3c5e9d058036fe73bb5c83987bd3fc0793fbe25d633cc4f37c2bd5f1d717cd2a81661bec08f0971dc6078e17bde372b89005e7738a0ebd501b896ca3e8315270ff64df7809dd912c372df61785a5085b3553b7872e39b1b1cc0ff5a6bc")] @@ -99,13 +99,10 @@ public interface ITaskObservable : System.IObservable public class ListObservable : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.IEnumerable, System.IObservable { public ListObservable(System.IObservable source) { } - [System.Runtime.CompilerServices.IndexerName("Item")] - public int Item { get; } - [System.Runtime.CompilerServices.IndexerName("Item")] - public bool Item { get; } + public int Count { get; } + public bool IsReadOnly { get; } public T this[int index] { get; set; } - [System.Runtime.CompilerServices.IndexerName("Item")] - public T Item { get; } + public T Value { get; } public void Add(T item) { } public void Clear() { } public bool Contains(T item) { } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Testing.approved.cs b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Testing.verified.cs similarity index 99% rename from Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Testing.approved.cs rename to Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Testing.verified.cs index 7c393f8996..b62f16132d 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Testing.approved.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Testing.verified.cs @@ -1,4 +1,4 @@ -[assembly: System.CLSCompliant(true)] +[assembly: System.CLSCompliant(true)] [assembly: System.Runtime.InteropServices.ComVisible(false)] [assembly: System.Runtime.Versioning.TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName=".NET Framework 4.6")] namespace Microsoft.Reactive.Testing diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/DiffPlexReporter.cs b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/DiffPlexReporter.cs index 56db8fb269..be20a58212 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/DiffPlexReporter.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/DiffPlexReporter.cs @@ -2,26 +2,18 @@ // The .NET Foundation licenses this file to you under the MIT License. // See the LICENSE file in the project root for more information. -using ApprovalTests.Core; +using System; using DiffPlex; using DiffPlex.DiffBuilder; using DiffPlex.DiffBuilder.Model; -using System.IO; -using Xunit.Abstractions; namespace ReactiveTests.Tests { - public class DiffPlexReporter : IApprovalFailureReporter + public class DiffPlexReporter { - public static DiffPlexReporter INSTANCE = new DiffPlexReporter(); - - public ITestOutputHelper Output { get; set; } - - public void Report(string approved, string received) + public void Report(string approvedText, string receivedText) { - var approvedText = File.Exists(approved) ? File.ReadAllText(approved) : string.Empty; - var receivedText = File.ReadAllText(received); - + #if(!DEBUG) var diffBuilder = new InlineDiffBuilder(new Differ()); var diff = diffBuilder.BuildDiffModel(approvedText, receivedText); @@ -40,8 +32,9 @@ public void Report(string approved, string received) break; } - Output.WriteLine("{0}{1}", prefix, line.Text); + Console.WriteLine("{0}{1}", prefix, line.Text); } + #endif } } } diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Tests.System.Reactive.ApiApprovals.csproj b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Tests.System.Reactive.ApiApprovals.csproj index 3f76175d6e..5f26ad6241 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Tests.System.Reactive.ApiApprovals.csproj +++ b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Tests.System.Reactive.ApiApprovals.csproj @@ -1,17 +1,14 @@  - net461 + net48 $(NoWarn);CS0618 - full - true - false - - - + + + @@ -29,9 +26,9 @@ + - From 0921aa0fdba6f0b8bcd187c1ebaf1c06439172da Mon Sep 17 00:00:00 2001 From: Claire Novotny Date: Sat, 28 Mar 2020 18:32:22 -0400 Subject: [PATCH 2/6] Re-enable approvals test --- azure-pipelines.rx.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/azure-pipelines.rx.yml b/azure-pipelines.rx.yml index be03222160..c4483f16c4 100644 --- a/azure-pipelines.rx.yml +++ b/azure-pipelines.rx.yml @@ -83,7 +83,6 @@ stages: projects: Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Tests.System.Reactive.ApiApprovals.csproj arguments: -c $(BuildConfiguration) --no-build --no-restore displayName: Run Api Approvals Tests - enabled: false - script: reportgenerator -reports:$(Agent.TempDirectory)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/Rx.NET/Source/coverlet/reports -reporttypes:"Cobertura" displayName: Create reports From 631fae5b56afd2d59732b8ce11a8670289c1e577 Mon Sep 17 00:00:00 2001 From: SimonCropp Date: Sun, 29 Mar 2020 09:44:55 +1100 Subject: [PATCH 3/6] Update LicenseHeaderTest.cs --- .../tests/Tests.System.Reactive/Tests/LicenseHeaderTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/LicenseHeaderTest.cs b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/LicenseHeaderTest.cs index ff5b9a3d3d..d91cc6b9a9 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive/Tests/LicenseHeaderTest.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive/Tests/LicenseHeaderTest.cs @@ -53,7 +53,7 @@ private int ScanPath(string path, StringBuilder error) || file.Contains("AssemblyInfo.cs") || file.Contains(".Designer.cs") || file.Contains(".Generated.cs") - || file.Contains(".approved.cs") + || file.Contains(".verified.cs") || file.Contains("Uwp.DeviceRunner") ) { From 5489db0ab9dc83d37e7720c1abd2093b3084424c Mon Sep 17 00:00:00 2001 From: SimonCropp Date: Sun, 29 Mar 2020 18:41:20 +1100 Subject: [PATCH 4/6] update verify --- ...erified.cs => ApiApprovalTests.Aliases.verified.cs} | 0 ...e.verified.cs => ApiApprovalTests.Core.verified.cs} | 0 ...erified.cs => ApiApprovalTests.Testing.verified.cs} | 0 .../Api/ApiApprovalTests.cs | 1 + .../DiffPlexReporter.cs | 10 +++++++--- .../Tests.System.Reactive.ApiApprovals.csproj | 4 +++- 6 files changed, 11 insertions(+), 4 deletions(-) rename Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/{Tests.Api.ApiApprovalTests.Aliases.verified.cs => ApiApprovalTests.Aliases.verified.cs} (100%) rename Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/{Tests.Api.ApiApprovalTests.Core.verified.cs => ApiApprovalTests.Core.verified.cs} (100%) rename Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/{Tests.Api.ApiApprovalTests.Testing.verified.cs => ApiApprovalTests.Testing.verified.cs} (100%) diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Aliases.verified.cs b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Aliases.verified.cs similarity index 100% rename from Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Aliases.verified.cs rename to Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Aliases.verified.cs diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Core.verified.cs b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.verified.cs similarity index 100% rename from Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Core.verified.cs rename to Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.verified.cs diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Testing.verified.cs b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Testing.verified.cs similarity index 100% rename from Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/Tests.Api.ApiApprovalTests.Testing.verified.cs rename to Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Testing.verified.cs diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.cs b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.cs index 4f66a6860f..b717891d97 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.cs @@ -24,6 +24,7 @@ public ApiApprovalTests(ITestOutputHelper output) : { verifySettings = new VerifySettings(); verifySettings.UseExtension("cs"); + verifySettings.OnVerifyMismatch(DiffPlexReporter.Report); } [Fact] diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/DiffPlexReporter.cs b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/DiffPlexReporter.cs index be20a58212..a900bc5972 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/DiffPlexReporter.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/DiffPlexReporter.cs @@ -3,19 +3,23 @@ // See the LICENSE file in the project root for more information. using System; +using System.IO; +using System.Threading.Tasks; using DiffPlex; using DiffPlex.DiffBuilder; using DiffPlex.DiffBuilder.Model; namespace ReactiveTests.Tests { - public class DiffPlexReporter + public static class DiffPlexReporter { - public void Report(string approvedText, string receivedText) + public static async Task Report(string receivedFile, string verifiedFile) { #if(!DEBUG) + var receivedText = File.ReadAllText(receivedFile); + var verifiedText = File.ReadAllText(verifiedFile); var diffBuilder = new InlineDiffBuilder(new Differ()); - var diff = diffBuilder.BuildDiffModel(approvedText, receivedText); + var diff = diffBuilder.BuildDiffModel(verifiedText, receivedText); foreach (var line in diff.Lines) { diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Tests.System.Reactive.ApiApprovals.csproj b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Tests.System.Reactive.ApiApprovals.csproj index 5f26ad6241..27262b2532 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Tests.System.Reactive.ApiApprovals.csproj +++ b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Tests.System.Reactive.ApiApprovals.csproj @@ -3,6 +3,8 @@ net48 $(NoWarn);CS0618 + false + false @@ -26,7 +28,7 @@ - + From 039331e99e9da24f81d178a777b034e4f87aa4c7 Mon Sep 17 00:00:00 2001 From: SimonCropp Date: Sun, 29 Mar 2020 18:41:31 +1100 Subject: [PATCH 5/6] Update ApiApprovalTests.cs --- .../Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.cs b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.cs index b717891d97..4c4064fd2d 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.cs +++ b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.cs @@ -17,7 +17,7 @@ namespace ReactiveTests.Tests.Api public class ApiApprovalTests : VerifyBase { - private VerifySettings verifySettings; + VerifySettings verifySettings; public ApiApprovalTests(ITestOutputHelper output) : base(output) From 65a355a96ad60cc3497356e3d9247764dba6e1f4 Mon Sep 17 00:00:00 2001 From: Claire Novotny Date: Sun, 29 Mar 2020 16:33:11 -0400 Subject: [PATCH 6/6] Update Tests.System.Reactive.ApiApprovals.csproj --- .../Tests.System.Reactive.ApiApprovals.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Tests.System.Reactive.ApiApprovals.csproj b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Tests.System.Reactive.ApiApprovals.csproj index 27262b2532..8f523b45d5 100644 --- a/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Tests.System.Reactive.ApiApprovals.csproj +++ b/Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Tests.System.Reactive.ApiApprovals.csproj @@ -3,7 +3,6 @@ net48 $(NoWarn);CS0618 - false false