Skip to content

Commit

Permalink
Merge pull request #1165 from SimonCropp/moveToVerify
Browse files Browse the repository at this point in the history
move to verify
  • Loading branch information
clairernovotny committed Mar 29, 2020
2 parents 7ad606b + 65a355a commit 9cb5907
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -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")]
Expand Down
Original file line number Diff line number Diff line change
@@ -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")]
Expand Down Expand Up @@ -99,13 +99,10 @@ public interface ITaskObservable<out T> : System.IObservable<T>
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) { }
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,50 @@
// 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)
VerifySettings verifySettings;

public ApiApprovalTests(ITestOutputHelper output) :
base(output)
{
DiffPlexReporter.INSTANCE.Output = output;
verifySettings = new VerifySettings();
verifySettings.UseExtension("cs");
verifySettings.OnVerifyMismatch(DiffPlexReporter.Report);
}

[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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,24 @@
// 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 System.IO;
using System.Threading.Tasks;
using DiffPlex;
using DiffPlex.DiffBuilder;
using DiffPlex.DiffBuilder.Model;
using System.IO;
using Xunit.Abstractions;

namespace ReactiveTests.Tests
{
public class DiffPlexReporter : IApprovalFailureReporter
public static class DiffPlexReporter
{
public static DiffPlexReporter INSTANCE = new DiffPlexReporter();

public ITestOutputHelper Output { get; set; }

public void Report(string approved, string received)
public static async Task Report(string receivedFile, string verifiedFile)
{
var approvedText = File.Exists(approved) ? File.ReadAllText(approved) : string.Empty;
var receivedText = File.ReadAllText(received);

#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)
{
Expand All @@ -40,8 +36,9 @@ public void Report(string approved, string received)
break;
}

Output.WriteLine("{0}{1}", prefix, line.Text);
Console.WriteLine("{0}{1}", prefix, line.Text);
}
#endif
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
<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>
<Deterministic>false</Deterministic>
</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>

Expand All @@ -29,9 +27,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Verify.Xunit" Version="1.27.0" />
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
)
{
Expand Down
1 change: 0 additions & 1 deletion azure-pipelines.rx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9cb5907

Please sign in to comment.