Skip to content

Commit e0cfcc7

Browse files
author
Emile Joubert
committed
Make WCF test runnable without windows console
1 parent 3b234b2 commit e0cfcc7

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

projects/examples/wcf/Test/Program.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static int Percent(int a, params int[] values)
140140

141141
static void WriteWholeLine()
142142
{
143-
int i = Console.WindowWidth;
143+
int i = ConsoleWidth();
144144
while (i > 1)
145145
{
146146
Console.Write(" ");
@@ -157,7 +157,7 @@ static void WriteWholeLine(string format, params object[] args)
157157
static void WriteWholeLine(string o)
158158
{
159159
Console.Write(o);
160-
int i = Console.WindowWidth;
160+
int i = ConsoleWidth();
161161
while (i > o.Length+1)
162162
{
163163
Console.Write(" ");
@@ -166,5 +166,10 @@ static void WriteWholeLine(string o)
166166
Console.Write("\n");
167167

168168
}
169+
170+
static int ConsoleWidth()
171+
{
172+
return Environment.GetEnvironmentVariable("TERM") == null ? Console.WindowWidth : 80;
173+
}
169174
}
170175
}

0 commit comments

Comments
 (0)