Commit 64e597b9 authored by Jeremy Meng's avatar Jeremy Meng

Update to NUnit 3.0. The ExpectedExceptionAttribute is gone.

parent c32ac415
...@@ -122,25 +122,36 @@ public void CanOpenSecuredConnection() ...@@ -122,25 +122,36 @@ public void CanOpenSecuredConnection()
} }
} }
[Test, ExpectedException(typeof(RedisConnectionException))] [Test]
public void CanNotOpenNonsenseConnection_IP() public void CanNotOpenNonsenseConnection_IP()
{
Assert.Throws<RedisConnectionException>(() =>
{ {
var log = new StringWriter(); var log = new StringWriter();
try { try {
using (var conn = ConnectionMultiplexer.Connect(Config.LocalHost + ":6500")) { } using (var conn = ConnectionMultiplexer.Connect(Config.LocalHost + ":6500")) { }
} finally { }
finally {
Console.WriteLine(log); Console.WriteLine(log);
} }
});
} }
[Test, ExpectedException(typeof(RedisConnectionException))]
[Test]
public void CanNotOpenNonsenseConnection_DNS() public void CanNotOpenNonsenseConnection_DNS()
{
Assert.Throws<RedisConnectionException>(() =>
{ {
var log = new StringWriter(); var log = new StringWriter();
try { try
{
using (var conn = ConnectionMultiplexer.Connect("doesnot.exist.ds.aasd981230d.com:6500", log)) { } using (var conn = ConnectionMultiplexer.Connect("doesnot.exist.ds.aasd981230d.com:6500", log)) { }
} finally { }
finally
{
Console.WriteLine(log); Console.WriteLine(log);
} }
});
} }
[Test] [Test]
......
...@@ -55,8 +55,10 @@ public void ExecuteWithEmptyStartingPoint() ...@@ -55,8 +55,10 @@ public void ExecuteWithEmptyStartingPoint()
} }
} }
[Test, ExpectedException(typeof(RedisServerException), ExpectedMessage = "WRONGTYPE Operation against a key holding the wrong kind of value")] [Test]
public void ExecuteWithNonHashStartingPoint() public void ExecuteWithNonHashStartingPoint()
{
Assert.Throws<RedisConnectionException>(() =>
{ {
using (var muxer = Config.GetUnsecuredConnection()) using (var muxer = Config.GetUnsecuredConnection())
{ {
...@@ -72,11 +74,14 @@ public void ExecuteWithNonHashStartingPoint() ...@@ -72,11 +74,14 @@ public void ExecuteWithNonHashStartingPoint()
{ {
conn.Wait(taskResult); conn.Wait(taskResult);
Assert.Fail(); Assert.Fail();
} catch(AggregateException ex) }
catch (AggregateException ex)
{ {
throw ex.InnerExceptions[0]; throw ex.InnerExceptions[0];
} }
} }
},
message: "WRONGTYPE Operation against a key holding the wrong kind of value");
} }
} }
} }
...@@ -44,9 +44,9 @@ ...@@ -44,9 +44,9 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <Reference Include="nunit.framework, Version=3.0.5715.30856, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <HintPath>..\packages\NUnit.3.0.0-beta-5\lib\net45\nunit.framework.dll</HintPath>
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath> <Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
......
...@@ -100,7 +100,6 @@ where Attribute.IsDefined(method, typeof(TestAttribute)) ...@@ -100,7 +100,6 @@ where Attribute.IsDefined(method, typeof(TestAttribute))
foreach (var test in tests) foreach (var test in tests)
{ {
var expectedFail = Attribute.GetCustomAttribute(test, typeof(ExpectedExceptionAttribute)) as ExpectedExceptionAttribute;
Console.Write(test.Name + ": "); Console.Write(test.Name + ": ");
Exception err = null; Exception err = null;
...@@ -131,35 +130,6 @@ where Attribute.IsDefined(method, typeof(TestAttribute)) ...@@ -131,35 +130,6 @@ where Attribute.IsDefined(method, typeof(TestAttribute))
err = ((AggregateException)err).InnerExceptions[0]; err = ((AggregateException)err).InnerExceptions[0];
} }
if (expectedFail != null)
{
if (err == null)
{
err = new NUnit.Framework.AssertionException("failed to fail");
}
else
{
int issues = 0;
if (expectedFail.ExpectedException != null && !expectedFail.ExpectedException.IsAssignableFrom(err.GetType()))
{
issues++;
}
if (expectedFail.ExpectedExceptionName != null && err.GetType().FullName != expectedFail.ExpectedExceptionName)
{
issues++;
}
if (expectedFail.ExpectedMessage != null && err.Message != expectedFail.ExpectedMessage)
{
issues++;
}
if (issues == 0) err = null;
else
{
err = new InvalidOperationException("Failed in a different way", err);
}
}
}
if (err == null) if (err == null)
{ {
Console.WriteLine("pass"); Console.WriteLine("pass");
......
...@@ -264,8 +264,10 @@ public void NonAsciiScripts() ...@@ -264,8 +264,10 @@ public void NonAsciiScripts()
} }
} }
[Test, ExpectedException(typeof(RedisServerException), ExpectedMessage = "oops")] [Test]
public void ScriptThrowsError() public void ScriptThrowsError()
{
Assert.Throws<RedisServerException>(() =>
{ {
using (var muxer = GetScriptConn()) using (var muxer = GetScriptConn())
{ {
...@@ -274,11 +276,14 @@ public void ScriptThrowsError() ...@@ -274,11 +276,14 @@ public void ScriptThrowsError()
try try
{ {
conn.Wait(result); conn.Wait(result);
} catch(AggregateException ex) }
catch (AggregateException ex)
{ {
throw ex.InnerExceptions[0]; throw ex.InnerExceptions[0];
} }
} }
},
message: "oops");
} }
[Test] [Test]
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="NUnit" version="2.6.4" targetFramework="net45" /> <package id="NUnit" version="3.0.0-beta-5" targetFramework="net45" />
</packages> </packages>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment