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

New unicode styles #67

Merged
merged 1 commit into from
Dec 18, 2018
Merged
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
94 changes: 94 additions & 0 deletions ConTabs.Tests/ConformanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,100 @@ public void TableStyledAsDotsShouldLookLikeThis()
tableString.ShouldBe(expected);
}

[Test]
public void TableStyledAsUnicodeDoubleWalledShouldLookLikeThis()
{
// Arrange
var listOfTestClasses = DataProvider.ListOfMinimalData(1);
var tableObj = Table<MinimalDataType>.Create(listOfTestClasses);
tableObj.TableStyle = Style.UnicodeDoubleWalled;

// Act
var tableString = tableObj.ToString();

// Assert
string expected = "";
expected += "╓──────╥──────╖" + Environment.NewLine;
expected += "║ IntA ║ IntB ║" + Environment.NewLine;
expected += "╟──────╫──────╢" + Environment.NewLine;
expected += "║ 1 ║ 3 ║" + Environment.NewLine;
expected += "╙──────╨──────╜";
tableString.ShouldBe(expected);
}

[Test]
public void TableStyledAsUnicodeDoubleWalledWithExplicitPaddingShouldLookLikeThis()
{
// Arrange
var listOfTestClasses = DataProvider.ListOfMinimalData(1);
var tableObj = Table<MinimalDataType>.Create(listOfTestClasses);
tableObj.TableStyle = Style.UnicodeDoubleWalled;
tableObj.Padding = new Padding(1, 2);

// Act
var tableString = tableObj.ToString();

// Assert
string expected = "";
expected += "╓────────╥────────╖" + Environment.NewLine;
expected += "║ ║ ║" + Environment.NewLine;
expected += "║ IntA ║ IntB ║" + Environment.NewLine;
expected += "║ ║ ║" + Environment.NewLine;
expected += "╟────────╫────────╢" + Environment.NewLine;
expected += "║ ║ ║" + Environment.NewLine;
expected += "║ 1 ║ 3 ║" + Environment.NewLine;
expected += "║ ║ ║" + Environment.NewLine;
expected += "╙────────╨────────╜";
tableString.ShouldBe(expected);
}

[Test]
public void TableStyledAsUnicodeDoubleFlooredShouldLookLikeThis()
{
// Arrange
var listOfTestClasses = DataProvider.ListOfMinimalData(1);
var tableObj = Table<MinimalDataType>.Create(listOfTestClasses);
tableObj.TableStyle = Style.UnicodeDoubleFloored;

// Act
var tableString = tableObj.ToString();

// Assert
string expected = "";
expected += "╒══════╤══════╕" + Environment.NewLine;
expected += "│ IntA │ IntB │" + Environment.NewLine;
expected += "╞══════╪══════╡" + Environment.NewLine;
expected += "│ 1 │ 3 │" + Environment.NewLine;
expected += "╘══════╧══════╛";
tableString.ShouldBe(expected);
}

[Test]
public void TableStyledAsUnicodeDoubleFlooredWithExplicitPaddingShouldLookLikeThis()
{
// Arrange
var listOfTestClasses = DataProvider.ListOfMinimalData(1);
var tableObj = Table<MinimalDataType>.Create(listOfTestClasses);
tableObj.TableStyle = Style.UnicodeDoubleFloored;
tableObj.Padding = new Padding(1, 2);

// Act
var tableString = tableObj.ToString();

// Assert
string expected = "";
expected += "╒════════╤════════╕" + Environment.NewLine;
expected += "│ │ │" + Environment.NewLine;
expected += "│ IntA │ IntB │" + Environment.NewLine;
expected += "│ │ │" + Environment.NewLine;
expected += "╞════════╪════════╡" + Environment.NewLine;
expected += "│ │ │" + Environment.NewLine;
expected += "│ 1 │ 3 │" + Environment.NewLine;
expected += "│ │ │" + Environment.NewLine;
expected += "╘════════╧════════╛";
tableString.ShouldBe(expected);
}

[Test]
public void BasicTableWithWrappedStringShouldLookLikeThis()
{
Expand Down
36 changes: 36 additions & 0 deletions ConTabs/Styles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,5 +143,41 @@ public Style(char wall, char floor, Corners corners)
TeeNoDown = ':',
TeeNoRight = ':'
});

/// <summary>
/// Built-in style
/// <para />
/// *May require Console.OutputEncoding = Encoding.Unicode;
/// </summary>
public static Style UnicodeDoubleWalled => new Style('║', '─', new Corners
{
CornerTopLeft = '╓',
CornerTopRight = '╖',
CornerBottomLeft = '╙',
CornerBottomRight = '╜',
Intersection = '╫',
TeeNoUp = '╥',
TeeNoLeft = '╟',
TeeNoDown = '╨',
TeeNoRight = '╢'
});

/// <summary>
/// Built-in style
/// <para />
/// *May require Console.OutputEncoding = Encoding.Unicode;
/// </summary>
public static Style UnicodeDoubleFloored => new Style('│', '═', new Corners
{
CornerTopLeft = '╒',
CornerTopRight = '╕',
CornerBottomLeft = '╘',
CornerBottomRight = '╛',
Intersection = '╪',
TeeNoUp = '╤',
TeeNoLeft = '╞',
TeeNoDown = '╧',
TeeNoRight = '╡'
});
}
}