Browse Source

move to verify

SimonCropp 5 years ago
parent
commit
4a7f9a9f15

+ 17 - 17
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)

+ 1 - 1
Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Aliases.approved.cs → 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")]

+ 4 - 7
Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.approved.cs → 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 @@ namespace System.Reactive
     public class ListObservable<T> : System.Collections.Generic.ICollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IList<T>, System.Collections.IEnumerable, System.IObservable<object>
     {
         public ListObservable(System.IObservable<T> 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) { }

+ 1 - 1
Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Testing.approved.cs → 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

+ 6 - 13
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 @@ namespace ReactiveTests.Tests
                         break;
                 }
 
-                Output.WriteLine("{0}{1}", prefix, line.Text);
+                Console.WriteLine("{0}{1}", prefix, line.Text);
             }
+            #endif
         }
     }
 }

+ 5 - 8
Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Tests.System.Reactive.ApiApprovals.csproj

@@ -1,17 +1,14 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFrameworks>net461</TargetFrameworks>
+    <TargetFrameworks>net48</TargetFrameworks>
     <NoWarn>$(NoWarn);CS0618</NoWarn>
-    <DebugType>full</DebugType>
-    <DebugSymbols>true</DebugSymbols>
-    <Optimize>false</Optimize>
   </PropertyGroup>
 
   <ItemGroup>
-    <Compile Remove="Api\*.approved.cs" />    
-    <Compile Remove="Api\*.received.cs" />    
-    <None Include="Api\*.approved.cs" />
+    <Compile Remove="Api\*.verified.cs" />
+    <Compile Remove="Api\*.received.cs" />
+    <None Include="Api\*.verified.cs" />
     <None Include="Api\*.received.cs" />
   </ItemGroup>
 
@@ -29,9 +26,9 @@
 
   <ItemGroup>
     <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
+    <PackageReference Include="Verify.Xunit" Version="1.26.1" />
     <PackageReference Include="xunit" Version="2.4.1" />
     <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
-    <PackageReference Include="ApprovalTests" Version="4.5.1" />
     <PackageReference Include="DiffPlex" Version="1.5.0" />
     <PackageReference Include="PublicApiGenerator" Version="10.0.2" />
   </ItemGroup>