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

Fluent assertions #3993

Draft
wants to merge 14 commits into
base: v2_develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
93 changes: 43 additions & 50 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,52 +1,45 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<!-- Enable Nuget Source Link for github -->
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="[8,9)" />

<PackageVersion Include="ColorHelper" Version="[1.8.1,2)" />
<PackageVersion Include="JetBrains.Annotations" Version="[2024.3.0,)" />
<PackageVersion Include="Microsoft.CodeAnalysis" Version="[4.13,5)" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="[4.13,5)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="[4.13,5)" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="[9.0.2,10)" />
<PackageVersion Include="System.IO.Abstractions" Version="[22.0.11,23)" />
<PackageVersion Include="System.Text.Json" Version="[8.0.5,9)" />
<PackageVersion Include="Wcwidth" Version="[2,3)" />

<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="[1.21.2,2)" />
<PackageVersion Include="Serilog" Version="4.2.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="9.0.0" />
<PackageVersion Include="Serilog.Sinks.Debug" Version="3.0.0" />
<PackageVersion Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageVersion Include="SixLabors.ImageSharp" Version="[3.1.7,4)" />
<PackageVersion Include="CsvHelper" Version="[33.0.1,34)" />
<PackageVersion Include="Microsoft.DotNet.PlatformAbstractions" Version="[3.1.6,4)" />
<PackageVersion Include="System.CommandLine" Version="[2.0.0-beta4.22272.1,3)" />

<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />

<PackageVersion Include="CommunityToolkit.Mvvm" Version="[8.4.0,9)" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="[9.0.2,10)" />
<PackageVersion Include="ReactiveUI" Version="[20.1.63,21)" />
<PackageVersion Include="ReactiveMarbles.ObservableEvents.SourceGenerator" Version="[1.3.1,2)" />
<PackageVersion Include="ReactiveUI.SourceGenerators" Version="[2.1.8,3)"/>

<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="[17.13,18)" />
<PackageVersion Include="Moq" Version="[4.20.72,5)" />
<PackageVersion Include="ReportGenerator" Version="[5.4.4,6)" />
<PackageVersion Include="TestableIO.System.IO.Abstractions.TestingHelpers" Version="[22.0.11,23)" />
<PackageVersion Include="xunit" Version="[2.9.3,3)" />
<PackageVersion Include="Xunit.Combinatorial" Version="[1.6.24,2)" />
<PackageVersion Include="xunit.runner.visualstudio" Version="[2.8.2,3)"/>
<PackageVersion Include="coverlet.collector" Version="[6.0.4,7)" />

</ItemGroup>

<ItemGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PackageVersion Include="Terminal.Gui" Version="2.0.0" />
</ItemGroup>

<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<!-- Enable Nuget Source Link for github -->
<PackageVersion Include="FluentAssertions" Version="8.2.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="[8,9)" />
<PackageVersion Include="ColorHelper" Version="[1.8.1,2)" />
<PackageVersion Include="JetBrains.Annotations" Version="[2024.3.0,)" />
<PackageVersion Include="Microsoft.CodeAnalysis" Version="[4.13,5)" />
<PackageVersion Include="Microsoft.CodeAnalysis.Common" Version="[4.13,5)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="[4.13,5)" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="[9.0.2,10)" />
<PackageVersion Include="System.IO.Abstractions" Version="[22.0.11,23)" />
<PackageVersion Include="System.Text.Json" Version="[8.0.5,9)" />
<PackageVersion Include="Wcwidth" Version="[2,3)" />
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="[1.21.2,2)" />
<PackageVersion Include="Serilog" Version="4.2.0" />
<PackageVersion Include="Serilog.Extensions.Logging" Version="9.0.0" />
<PackageVersion Include="Serilog.Sinks.Debug" Version="3.0.0" />
<PackageVersion Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageVersion Include="SixLabors.ImageSharp" Version="[3.1.7,4)" />
<PackageVersion Include="CsvHelper" Version="[33.0.1,34)" />
<PackageVersion Include="Microsoft.DotNet.PlatformAbstractions" Version="[3.1.6,4)" />
<PackageVersion Include="System.CommandLine" Version="[2.0.0-beta4.22272.1,3)" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="CommunityToolkit.Mvvm" Version="[8.4.0,9)" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="[9.0.2,10)" />
<PackageVersion Include="ReactiveUI" Version="[20.1.63,21)" />
<PackageVersion Include="ReactiveMarbles.ObservableEvents.SourceGenerator" Version="[1.3.1,2)" />
<PackageVersion Include="ReactiveUI.SourceGenerators" Version="[2.1.8,3)" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="[17.13,18)" />
<PackageVersion Include="Moq" Version="[4.20.72,5)" />
<PackageVersion Include="ReportGenerator" Version="[5.4.4,6)" />
<PackageVersion Include="TestableIO.System.IO.Abstractions.TestingHelpers" Version="[22.0.11,23)" />
<PackageVersion Include="xunit" Version="[2.9.3,3)" />
<PackageVersion Include="Xunit.Combinatorial" Version="[1.6.24,2)" />
<PackageVersion Include="xunit.runner.visualstudio" Version="[2.8.2,3)" />
<PackageVersion Include="coverlet.collector" Version="[6.0.4,7)" />
</ItemGroup>
<ItemGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PackageVersion Include="Terminal.Gui" Version="2.0.0" />
</ItemGroup>
</Project>
1 change: 1 addition & 0 deletions Terminal.Gui/Terminal.Gui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<InternalsVisibleTo Include="StressTests" />
<InternalsVisibleTo Include="IntegrationTests" />
<InternalsVisibleTo Include="TerminalGuiDesigner" />
<InternalsVisibleTo Include="TerminalGuiFluentTesting" />
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
</ItemGroup>
<!-- =================================================================== -->
Expand Down
7 changes: 7 additions & 0 deletions Terminal.sln
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.2.32427.441
Expand Down Expand Up @@ -62,6 +63,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StressTests", "Tests\Stress
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests.Parallelizable", "Tests\UnitTestsParallelizable\UnitTests.Parallelizable.csproj", "{DE780834-190A-8277-51FD-750CC666E82D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TerminalGuiFluentTesting", "TerminalGuiFluentTesting\TerminalGuiFluentTesting.csproj", "{2DBA7BDC-17AE-474B-A507-00807D087607}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -116,6 +119,10 @@ Global
{DE780834-190A-8277-51FD-750CC666E82D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE780834-190A-8277-51FD-750CC666E82D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE780834-190A-8277-51FD-750CC666E82D}.Release|Any CPU.Build.0 = Release|Any CPU
{2DBA7BDC-17AE-474B-A507-00807D087607}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2DBA7BDC-17AE-474B-A507-00807D087607}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DBA7BDC-17AE-474B-A507-00807D087607}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DBA7BDC-17AE-474B-A507-00807D087607}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
59 changes: 59 additions & 0 deletions TerminalGuiFluentTesting/ClassDiagram1.cd
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="TerminalGuiFluentTesting.With" Collapsed="true">
<Position X="0.5" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAIAAAAAA=</HashCode>
<FileName>With.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="TerminalGuiFluentTesting.FakeInput&lt;T&gt;" Collapsed="true">
<Position X="7" Y="1.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AQAAAAAAACAAAQEAAAAgAAAAAAAAAAAAAAAAAAAAAAI=</HashCode>
<FileName>FakeInput.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="TerminalGuiFluentTesting.FakeNetInput" Collapsed="true">
<Position X="8.25" Y="2.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>FakeNetInput.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="TerminalGuiFluentTesting.FakeWindowsInput" Collapsed="true">
<Position X="6" Y="2.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>FakeWindowsInput.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="TerminalGuiFluentTesting.FakeOutput" Collapsed="true" BaseTypeListCollapsed="true">
<Position X="5.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAgCAAgAAAAAAAAAAAAAAAQAAAMAAAAAEAAAA=</HashCode>
<FileName>FakeOutput.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="TerminalGuiFluentTesting.GuiTestContext&lt;T&gt;" BaseTypeListCollapsed="true">
<Position X="2.25" Y="0.5" Width="2.25" />
<Compartments>
<Compartment Name="Fields" Collapsed="true" />
</Compartments>
<TypeIdentifier>
<HashCode>ABJAAAIAACBAAQAAgYAAAAAgABIEgAQAIAAIBACAIgA=</HashCode>
<FileName>GuiTestContext.cs</FileName>
</TypeIdentifier>
<ShowAsAssociation>
<Field Name="_output" />
<Field Name="_winInput" />
<Field Name="_netInput" />
</ShowAsAssociation>
<Lollipop Position="0.2" />
</Class>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>
34 changes: 34 additions & 0 deletions TerminalGuiFluentTesting/FakeInput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Collections.Concurrent;
using Terminal.Gui;

namespace TerminalGuiFluentTesting;

internal class FakeInput<T> : IConsoleInput<T>
{
private readonly CancellationToken _hardStopToken;

private readonly CancellationTokenSource _timeoutCts;

public FakeInput (CancellationToken hardStopToken)

Check warning on line 12 in TerminalGuiFluentTesting/FakeInput.cs

View workflow job for this annotation

GitHub Actions / build_release

Non-nullable property 'InputBuffer' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
{
_hardStopToken = hardStopToken;

// Create a timeout-based cancellation token too to prevent tests ever fully hanging
_timeoutCts = new (With.Timeout);
}

/// <inheritdoc/>
public void Dispose () { }

/// <inheritdoc/>
public void Initialize (ConcurrentQueue<T> inputBuffer) { InputBuffer = inputBuffer; }

public ConcurrentQueue<T> InputBuffer { get; set; }

/// <inheritdoc/>
public void Run (CancellationToken token)
{
// Blocks until either the token or the hardStopToken is cancelled.
WaitHandle.WaitAny (new [] { token.WaitHandle, _hardStopToken.WaitHandle, _timeoutCts.Token.WaitHandle });
}
}
6 changes: 6 additions & 0 deletions TerminalGuiFluentTesting/FakeNetInput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Terminal.Gui;

namespace TerminalGuiFluentTesting;

internal class FakeNetInput (CancellationToken hardStopToken) : FakeInput<ConsoleKeyInfo> (hardStopToken), INetInput
{ }
28 changes: 28 additions & 0 deletions TerminalGuiFluentTesting/FakeOutput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.Drawing;
using Terminal.Gui;

namespace TerminalGuiFluentTesting;

internal class FakeOutput : IConsoleOutput
{
public IOutputBuffer LastBuffer { get; set; }

Check warning on line 8 in TerminalGuiFluentTesting/FakeOutput.cs

View workflow job for this annotation

GitHub Actions / build_release

Non-nullable property 'LastBuffer' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier or declaring the property as nullable.
public Size Size { get; set; }

/// <inheritdoc/>
public void Dispose () { }

/// <inheritdoc/>
public void Write (ReadOnlySpan<char> text) { }

/// <inheritdoc/>
public void Write (IOutputBuffer buffer) { LastBuffer = buffer; }

/// <inheritdoc/>
public Size GetWindowSize () { return Size; }

/// <inheritdoc/>
public void SetCursorVisibility (CursorVisibility visibility) { }

/// <inheritdoc/>
public void SetCursorPosition (int col, int row) { }
}
6 changes: 6 additions & 0 deletions TerminalGuiFluentTesting/FakeWindowsInput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using Terminal.Gui;

namespace TerminalGuiFluentTesting;

internal class FakeWindowsInput (CancellationToken hardStopToken) : FakeInput<WindowsConsole.InputRecord> (hardStopToken), IWindowsInput
{ }
Loading
Loading