-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support to configure number alignment
- Loading branch information
1 parent
8601de2
commit 7cc74a3
Showing
6 changed files
with
149 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace ConsoleTables.Tests | ||
{ | ||
public class ConsoleTableTest | ||
{ | ||
[Fact] | ||
public void ShouldBeToStringFromList() | ||
{ | ||
var users = new List<User> | ||
{ | ||
new User { Name = "Alexandre" , Age = 36 } | ||
}; | ||
var table = ConsoleTable.From(users).ToString(); | ||
|
||
Assert.Equal($@" ------------------- | ||
| Name | Age | | ||
------------------- | ||
| Alexandre | 36 | | ||
------------------- | ||
Count: 1", table); | ||
} | ||
|
||
[Fact] | ||
public void NumberShouldBeRightAligned() | ||
{ | ||
var users = new List<User> | ||
{ | ||
new User { Name = "Alexandre" , Age = 36 } | ||
}; | ||
var table = ConsoleTable | ||
.From(users) | ||
.Configure(o => o.NumberRigthAligned = true) | ||
.ToString(); | ||
|
||
Assert.Equal($@" ------------------- | ||
| Name | Age | | ||
------------------- | ||
| Alexandre | 36 | | ||
------------------- | ||
Count: 1", table); | ||
} | ||
|
||
class User | ||
{ | ||
public string Name { get; set; } | ||
public int Age { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.0</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
|
||
<ApplicationIcon /> | ||
|
||
<OutputType>Library</OutputType> | ||
|
||
<StartupObject /> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> | ||
<PackageReference Include="xunit" Version="2.4.0" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\src\ConsoleTables\ConsoleTables.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters