Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move to verify #1165

Merged
merged 7 commits into from
Mar 29, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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.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,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);

Expand All @@ -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
}
}
}
Original file line number Diff line number Diff line change
@@ -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>

Expand All @@ -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>
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, LGTM!

|| file.Contains("Uwp.DeviceRunner")
)
{
Expand Down