Skip to content

Commit

Permalink
Merge pull request #67 from oisinmcl/develop
Browse files Browse the repository at this point in the history
New unicode styles
  • Loading branch information
tdwright authored Dec 18, 2018
2 parents bc41944 + 5ae7d71 commit 4320620
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 0 deletions.
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 = '╡'
});
}
}

0 comments on commit 4320620

Please sign in to comment.