Skip to content

Commit 0f23e06

Browse files
committed
mono switches
1 parent 39d0bcc commit 0f23e06

File tree

4 files changed

+94
-77
lines changed

4 files changed

+94
-77
lines changed

projects/client/Unit.Runner/Program.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@ public class Program
1010
{
1111
public static void Main(string[] args)
1212
{
13-
//#if NETFX_CORE
14-
Console.WriteLine("netfx");
15-
//#endif
16-
1713
var writter = new ExtendedTextWrapper(Console.Out);
18-
new AutoRun(typeof(TestAmqpUri).GetTypeInfo().Assembly).Execute(args, writter, Console.In);
14+
new AutoRun(typeof(TestAmqpUri).GetTypeInfo().Assembly).Execute(args, writter, null);
1915
}
2016
}
2117
}

projects/client/Unit/project.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
},
1717
"netcoreapp1.0": {
1818
"imports": "dnxcore50",
19+
"buildOptions": {
20+
"define": [ "CORECLR" ]
21+
},
1922
"dependencies": {
2023
"Microsoft.NETCore.App": {
2124
"type": "platform",

projects/client/Unit/src/unit/Fixtures.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ protected Process ExecRabbitMQCtl(string args)
411411
{
412412
rabbitmqctlPath = envVariable;
413413
}
414-
else if (IsRunningOnMono())
414+
else if (IsRunningOnMonoOrDotNetCore())
415415
{
416416
rabbitmqctlPath = "../../../../rabbit/scripts/rabbitmqctl";
417417
}
@@ -449,7 +449,7 @@ protected Process ExecCommand(string ctl, string args, string changeDirTo)
449449
}
450450

451451
string cmd;
452-
if(IsRunningOnMono()) {
452+
if(IsRunningOnMonoOrDotNetCore()) {
453453
cmd = ctl;
454454
} else {
455455
cmd = "cmd.exe";
@@ -485,9 +485,13 @@ protected void ReportExecFailure(String cmd, String args, String msg)
485485
Console.WriteLine("Failure while running " + cmd + " " + args + ":\n" + msg);
486486
}
487487

488-
public static bool IsRunningOnMono()
488+
public static bool IsRunningOnMonoOrDotNetCore()
489489
{
490-
return true;// Type.GetType("Mono.Runtime") != null;
490+
#if CORECLR
491+
return true;
492+
#else
493+
return Type.GetType("Mono.Runtime") != null;
494+
#endif
491495
}
492496

493497
//

projects/client/Unit/src/unit/TestAmqpUri.cs

Lines changed: 82 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -51,83 +51,89 @@ public class TestAmqpUri
5151
[Test, Category("MonoBug")]
5252
public void TestAmqpUriParseFail()
5353
{
54-
/* Various failure cases */
55-
ParseFailWith<ArgumentException>("http://www.rabbitmq.com");
56-
ParseFailWith<UriFormatException>("amqp://foo:bar:baz");
57-
ParseFailWith<UriFormatException>("amqp://foo[::1]");
58-
ParseFailWith<UriFormatException>("amqp://foo:[::1]");
59-
ParseFailWith<UriFormatException>("amqp://foo:1000xyz");
60-
ParseFailWith<UriFormatException>("amqp://foo:1000000");
61-
ParseFailWith<ArgumentException>("amqp://foo/bar/baz");
54+
if(IsRunningOnMono() == false)
55+
{
56+
/* Various failure cases */
57+
ParseFailWith<ArgumentException>("http://www.rabbitmq.com");
58+
ParseFailWith<UriFormatException>("amqp://foo:bar:baz");
59+
ParseFailWith<UriFormatException>("amqp://foo[::1]");
60+
ParseFailWith<UriFormatException>("amqp://foo:[::1]");
61+
ParseFailWith<UriFormatException>("amqp://foo:1000xyz");
62+
ParseFailWith<UriFormatException>("amqp://foo:1000000");
63+
ParseFailWith<ArgumentException>("amqp://foo/bar/baz");
6264

63-
ParseFailWith<UriFormatException>("amqp://foo%1");
64-
ParseFailWith<UriFormatException>("amqp://foo%1x");
65-
ParseFailWith<UriFormatException>("amqp://foo%xy");
65+
ParseFailWith<UriFormatException>("amqp://foo%1");
66+
ParseFailWith<UriFormatException>("amqp://foo%1x");
67+
ParseFailWith<UriFormatException>("amqp://foo%xy");
68+
}
6669
}
6770

6871
[Test, Category("MonoBug")]
6972
public void TestAmqpUriParseSucceed()
7073
{
71-
/* From the spec */
72-
ParseSuccess("amqp://user:pass@host:10000/vhost",
73-
"user", "pass", "host", 10000, "vhost");
74-
ParseSuccess("aMQps://user%61:%61pass@host:10000/v%2fhost",
75-
"usera", "apass", "host", 10000, "v/host");
76-
ParseSuccess("amqp://localhost", "guest", "guest", "localhost", 5672, "/");
77-
ParseSuccess("amqp://:@localhost/", "", "", "localhost", 5672, "/");
78-
ParseSuccess("amqp://user@localhost",
79-
"user", "guest", "localhost", 5672, "/");
80-
ParseSuccess("amqp://user:pass@localhost",
81-
"user", "pass", "localhost", 5672, "/");
82-
ParseSuccess("amqp://host", "guest", "guest", "host", 5672, "/");
83-
ParseSuccess("amqp://localhost:10000",
84-
"guest", "guest", "localhost", 10000, "/");
85-
ParseSuccess("amqp://localhost/vhost",
86-
"guest", "guest", "localhost", 5672, "vhost");
87-
ParseSuccess("amqp://host/", "guest", "guest", "host", 5672, "/");
88-
ParseSuccess("amqp://host/%2f",
89-
"guest", "guest", "host", 5672, "/");
90-
ParseSuccess("amqp://[::1]", "guest", "guest",
91-
IPv6Loopbacks,
92-
5672, "/");
74+
if(IsRunningOnMono() == false)
75+
{
76+
/* From the spec */
77+
ParseSuccess("amqp://user:pass@host:10000/vhost",
78+
"user", "pass", "host", 10000, "vhost");
79+
ParseSuccess("aMQps://user%61:%61pass@host:10000/v%2fhost",
80+
"usera", "apass", "host", 10000, "v/host");
81+
ParseSuccess("amqp://localhost", "guest", "guest", "localhost", 5672, "/");
82+
ParseSuccess("amqp://:@localhost/", "", "", "localhost", 5672, "/");
83+
ParseSuccess("amqp://user@localhost",
84+
"user", "guest", "localhost", 5672, "/");
85+
ParseSuccess("amqp://user:pass@localhost",
86+
"user", "pass", "localhost", 5672, "/");
87+
ParseSuccess("amqp://host", "guest", "guest", "host", 5672, "/");
88+
ParseSuccess("amqp://localhost:10000",
89+
"guest", "guest", "localhost", 10000, "/");
90+
ParseSuccess("amqp://localhost/vhost",
91+
"guest", "guest", "localhost", 5672, "vhost");
92+
ParseSuccess("amqp://host/", "guest", "guest", "host", 5672, "/");
93+
ParseSuccess("amqp://host/%2f",
94+
"guest", "guest", "host", 5672, "/");
95+
ParseSuccess("amqp://[::1]", "guest", "guest",
96+
IPv6Loopbacks,
97+
5672, "/");
9398

94-
/* Various other success cases */
95-
ParseSuccess("amqp://host:100",
96-
"guest", "guest", "host", 100, "/");
97-
ParseSuccess("amqp://[::1]:100",
98-
"guest", "guest",
99-
IPv6Loopbacks,
100-
100, "/");
99+
/* Various other success cases */
100+
ParseSuccess("amqp://host:100",
101+
"guest", "guest", "host", 100, "/");
102+
ParseSuccess("amqp://[::1]:100",
103+
"guest", "guest",
104+
IPv6Loopbacks,
105+
100, "/");
101106

102-
ParseSuccess("amqp://host/blah",
103-
"guest", "guest", "host", 5672, "blah");
104-
ParseSuccess("amqp://host:100/blah",
105-
"guest", "guest", "host", 100, "blah");
106-
ParseSuccess("amqp://localhost:100/blah",
107-
"guest", "guest", "localhost", 100, "blah");
108-
ParseSuccess("amqp://[::1]/blah",
109-
"guest", "guest",
110-
IPv6Loopbacks,
111-
5672, "blah");
112-
ParseSuccess("amqp://[::1]:100/blah",
113-
"guest", "guest",
114-
IPv6Loopbacks,
115-
100, "blah");
107+
ParseSuccess("amqp://host/blah",
108+
"guest", "guest", "host", 5672, "blah");
109+
ParseSuccess("amqp://host:100/blah",
110+
"guest", "guest", "host", 100, "blah");
111+
ParseSuccess("amqp://localhost:100/blah",
112+
"guest", "guest", "localhost", 100, "blah");
113+
ParseSuccess("amqp://[::1]/blah",
114+
"guest", "guest",
115+
IPv6Loopbacks,
116+
5672, "blah");
117+
ParseSuccess("amqp://[::1]:100/blah",
118+
"guest", "guest",
119+
IPv6Loopbacks,
120+
100, "blah");
116121

117-
ParseSuccess("amqp://user:pass@host",
118-
"user", "pass", "host", 5672, "/");
119-
ParseSuccess("amqp://user:pass@host:100",
120-
"user", "pass", "host", 100, "/");
121-
ParseSuccess("amqp://user:pass@localhost:100",
122-
"user", "pass", "localhost", 100, "/");
123-
ParseSuccess("amqp://user:pass@[::1]",
124-
"user", "pass",
125-
IPv6Loopbacks,
126-
5672, "/");
127-
ParseSuccess("amqp://user:pass@[::1]:100",
128-
"user", "pass",
129-
IPv6Loopbacks,
130-
100, "/");
122+
ParseSuccess("amqp://user:pass@host",
123+
"user", "pass", "host", 5672, "/");
124+
ParseSuccess("amqp://user:pass@host:100",
125+
"user", "pass", "host", 100, "/");
126+
ParseSuccess("amqp://user:pass@localhost:100",
127+
"user", "pass", "localhost", 100, "/");
128+
ParseSuccess("amqp://user:pass@[::1]",
129+
"user", "pass",
130+
IPv6Loopbacks,
131+
5672, "/");
132+
ParseSuccess("amqp://user:pass@[::1]:100",
133+
"user", "pass",
134+
IPv6Loopbacks,
135+
100, "/");
136+
}
131137
}
132138

133139
private static void AssertUriPartEquivalence(string user, string password, int port, string vhost, ConnectionFactory cf)
@@ -158,5 +164,13 @@ private void ParseSuccess(string uri, string user, string password,
158164
AssertUriPartEquivalence(user, password, port, vhost, factory);
159165
Assert.IsTrue((Array.IndexOf(hosts, factory.HostName)) != -1);
160166
}
167+
public static bool IsRunningOnMono()
168+
{
169+
#if CORECLR
170+
return false;
171+
#else
172+
return Type.GetType("Mono.Runtime") != null;
173+
#endif
174+
}
161175
}
162176
}

0 commit comments

Comments
 (0)