Commit 5633bbb2 authored by RogerBest's avatar RogerBest

Updated to NUnit 3.0.0 Beta 5

parent 2bca2a52
This diff is collapsed.
...@@ -12,7 +12,8 @@ public sealed class BatchWrapperTests ...@@ -12,7 +12,8 @@ public sealed class BatchWrapperTests
private Mock<IBatch> mock; private Mock<IBatch> mock;
private BatchWrapper wrapper; private BatchWrapper wrapper;
[TestFixtureSetUp] //[TestFixtureSetUp]
[OneTimeSetUpAttribute]
public void Initialize() public void Initialize()
{ {
mock = new Mock<IBatch>(); mock = new Mock<IBatch>();
......
This diff is collapsed.
...@@ -125,7 +125,7 @@ public void ClientName() ...@@ -125,7 +125,7 @@ public void ClientName()
} }
[Test] [Test]
[ExpectedException(typeof(RedisCommandException), ExpectedMessage = "This operation has been disabled in the command-map and cannot be used: CONFIG")] // [ExpectedException(typeof(RedisCommandException), ExpectedMessage = "This operation has been disabled in the command-map and cannot be used: CONFIG")]
public void ReadConfigWithConfigDisabled() public void ReadConfigWithConfigDisabled()
{ {
using (var muxer = Create(allowAdmin: true, disabledCommands: new[] { "config", "info" })) using (var muxer = Create(allowAdmin: true, disabledCommands: new[] { "config", "info" }))
......
...@@ -15,7 +15,8 @@ public sealed class DatabaseWrapperTests ...@@ -15,7 +15,8 @@ public sealed class DatabaseWrapperTests
private Mock<IDatabase> mock; private Mock<IDatabase> mock;
private DatabaseWrapper wrapper; private DatabaseWrapper wrapper;
[TestFixtureSetUp] //[TestFixtureSetUp]
[OneTimeSetUp]
public void Initialize() public void Initialize()
{ {
mock = new Mock<IDatabase>(); mock = new Mock<IDatabase>();
...@@ -289,10 +290,10 @@ public void KeyPersist() ...@@ -289,10 +290,10 @@ public void KeyPersist()
} }
[Test] [Test]
[ExpectedException(typeof(NotSupportedException))] //[ExpectedException(typeof(NotSupportedException))]
public void KeyRandom() public void KeyRandom()
{ {
wrapper.KeyRandom(); Assert.Throws(typeof(NotSupportedException), delegate { wrapper.KeyRandom(); });
} }
[Test] [Test]
......
...@@ -23,15 +23,23 @@ public void UnkonwnKeywordHandling_Ignore() ...@@ -23,15 +23,23 @@ public void UnkonwnKeywordHandling_Ignore()
{ {
var options = ConfigurationOptions.Parse("ssl2=true", true); var options = ConfigurationOptions.Parse("ssl2=true", true);
} }
[Test, ExpectedException(typeof(ArgumentException), ExpectedMessage = "Keyword 'ssl2' is not supported")] [Test]
//, ExpectedException(typeof(ArgumentException), ExpectedMessage = "Keyword 'ssl2' is not supported")]
public void UnkonwnKeywordHandling_ExplicitFail() public void UnkonwnKeywordHandling_ExplicitFail()
{ {
var options = ConfigurationOptions.Parse("ssl2=true", false); Exception ex = Assert.Throws(typeof(ArgumentException), delegate {
var options = ConfigurationOptions.Parse("ssl2=true", false);
});
Assert.That(ex.Message.Equals("Keyword 'ssl2' is not supported"));
} }
[Test, ExpectedException(typeof(ArgumentException), ExpectedMessage = "Keyword 'ssl2' is not supported")] [Test]
//, ExpectedException(typeof(ArgumentException), ExpectedMessage = "Keyword 'ssl2' is not supported")]
public void UnkonwnKeywordHandling_ImplicitFail() public void UnkonwnKeywordHandling_ImplicitFail()
{ {
var options = ConfigurationOptions.Parse("ssl2=true"); Exception ex = Assert.Throws(typeof(ArgumentException), delegate {
var options = ConfigurationOptions.Parse("ssl2=true");
});
Assert.That(ex.Message.Equals("Keyword 'ssl2' is not supported"));
} }
} }
} }
...@@ -14,16 +14,21 @@ protected override string GetConfiguration() ...@@ -14,16 +14,21 @@ protected override string GetConfiguration()
return PrimaryServer + ":" + SecurePort + "," + PrimaryServer + ":" + PrimaryPort + ",password=" + SecurePassword; return PrimaryServer + ":" + SecurePort + "," + PrimaryServer + ":" + PrimaryPort + ",password=" + SecurePassword;
} }
[Test, ExpectedException(typeof(RedisCommandException), ExpectedMessage = "Command cannot be issued to a slave: FLUSHDB")] [Test]
//, ExpectedException(typeof(RedisCommandException), ExpectedMessage = "Command cannot be issued to a slave: FLUSHDB")]
public void CannotFlushSlave() public void CannotFlushSlave()
{ {
ConfigurationOptions config = GetMasterSlaveConfig(); Exception ex = Assert.Throws(typeof(RedisCommandException), delegate {
using (var conn = ConnectionMultiplexer.Connect(config)) ConfigurationOptions config = GetMasterSlaveConfig();
{ using (var conn = ConnectionMultiplexer.Connect(config))
var servers = Array.ConvertAll(conn.GetEndPoints(), e => conn.GetServer(e)); {
var slave = servers.First(x => x.IsSlave); var servers = Array.ConvertAll(conn.GetEndPoints(), e => conn.GetServer(e));
slave.FlushDatabase(); var slave = servers.First(x => x.IsSlave);
} slave.FlushDatabase();
}
});
Assert.That(ex.Message.Equals("Command cannot be issued to a slave: FLUSHDB"));
} }
[Test] [Test]
......
This diff is collapsed.
...@@ -68,14 +68,17 @@ public void Connect() ...@@ -68,14 +68,17 @@ public void Connect()
[Test] [Test]
[TestCase("wrong")] [TestCase("wrong")]
[TestCase("")] [TestCase("")]
[ExpectedException(typeof(RedisConnectionException), ExpectedMessage = "No connection is available to service this operation: PING")] //[ExpectedException(typeof(RedisConnectionException), ExpectedMessage = "No connection is available to service this operation: PING")]
public void ConnectWithWrongPassword(string password) public void ConnectWithWrongPassword(string password)
{ {
SetExpectedAmbientFailureCount(-1); Exception ex = Assert.Throws(typeof(RedisConnectionException), delegate {
using (var server = Create(password: password, checkConnect: false)) SetExpectedAmbientFailureCount(-1);
{ using (var server = Create(password: password, checkConnect: false))
server.GetDatabase().Ping(); {
} server.GetDatabase().Ping();
}
});
Assert.That(ex.Message.Equals("No connection is available to service this operation: PING"));
} }
} }
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
namespace StackExchange.Redis.Tests namespace StackExchange.Redis.Tests
{ {
[TestFixture, Ignore] [TestFixture, Ignore("reason?")]
public class Sentinel public class Sentinel
{ {
// TODO fill in these constants before running tests // TODO fill in these constants before running tests
...@@ -100,7 +100,7 @@ public void SentinelSlavesTest() ...@@ -100,7 +100,7 @@ public void SentinelSlavesTest()
} }
} }
[Test, Ignore] [Test, Ignore("reason?")]
public void SentinelFailoverTest() public void SentinelFailoverTest()
{ {
Server.SentinelFailover(ServiceName); Server.SentinelFailover(ServiceName);
......
...@@ -66,9 +66,9 @@ ...@@ -66,9 +66,9 @@
<HintPath>..\packages\Moq.4.2.1502.0911\lib\net40\Moq.dll</HintPath> <HintPath>..\packages\Moq.4.2.1502.0911\lib\net40\Moq.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<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" />
......
...@@ -11,7 +11,8 @@ public sealed class TransactionWrapperTests ...@@ -11,7 +11,8 @@ public sealed class TransactionWrapperTests
private Mock<ITransaction> mock; private Mock<ITransaction> mock;
private TransactionWrapper wrapper; private TransactionWrapper wrapper;
[TestFixtureSetUp] //[TestFixtureSetUp]
[OneTimeSetUp]
public void Initialize() public void Initialize()
{ {
mock = new Mock<ITransaction>(); mock = new Mock<ITransaction>();
......
using System; using System;
using NUnit.Framework; using NUnit.Framework;
using StackExchange.Redis.KeyspaceIsolation; using StackExchange.Redis.KeyspaceIsolation;
namespace StackExchange.Redis.Tests namespace StackExchange.Redis.Tests
{ {
[TestFixture] [TestFixture]
public class WithKeyPrefixTests : TestBase public class WithKeyPrefixTests : TestBase
{ {
[Test] [Test]
public void BlankPrefixYieldsSame_Bytes() public void BlankPrefixYieldsSame_Bytes()
{ {
using (var conn = Create()) using (var conn = Create())
{ {
var raw = conn.GetDatabase(1); var raw = conn.GetDatabase(1);
var prefixed = raw.WithKeyPrefix(new byte[0]); var prefixed = raw.WithKeyPrefix(new byte[0]);
Assert.AreSame(raw, prefixed); Assert.AreSame(raw, prefixed);
} }
} }
[Test] [Test]
public void BlankPrefixYieldsSame_String() public void BlankPrefixYieldsSame_String()
{ {
using (var conn = Create()) using (var conn = Create())
{ {
var raw = conn.GetDatabase(1); var raw = conn.GetDatabase(1);
var prefixed = raw.WithKeyPrefix(""); var prefixed = raw.WithKeyPrefix("");
Assert.AreSame(raw, prefixed); Assert.AreSame(raw, prefixed);
} }
} }
[Test, ExpectedException(typeof(ArgumentNullException))] [Test]
public void NullPrefixIsError_Bytes() //, ExpectedException(typeof(ArgumentNullException))]
{ public void NullPrefixIsError_Bytes()
using (var conn = Create()) {
{ Assert.Throws(typeof(ArgumentNullException), delegate {
var raw = conn.GetDatabase(1); using (var conn = Create())
var prefixed = raw.WithKeyPrefix((byte[])null); {
} var raw = conn.GetDatabase(1);
} var prefixed = raw.WithKeyPrefix((byte[])null);
[Test, ExpectedException(typeof(ArgumentNullException))] }
public void NullPrefixIsError_String() });
{ }
using (var conn = Create()) [Test]
{ //, ExpectedException(typeof(ArgumentNullException))]
var raw = conn.GetDatabase(1); public void NullPrefixIsError_String()
var prefixed = raw.WithKeyPrefix((string)null); {
} Assert.Throws(typeof(ArgumentNullException), delegate {
} using (var conn = Create())
{
[Test, ExpectedException(typeof(ArgumentNullException))] var raw = conn.GetDatabase(1);
[TestCase("abc")] var prefixed = raw.WithKeyPrefix((string)null);
[TestCase("")] }
[TestCase(null)] });
public void NullDatabaseIsError(string prefix) }
{
IDatabase raw = null; [Test]
var prefixed = raw.WithKeyPrefix(prefix); //, ExpectedException(typeof(ArgumentNullException))]
} [TestCase("abc")]
[Test] [TestCase("")]
public void BasicSmokeTest() [TestCase(null)]
{ public void NullDatabaseIsError(string prefix)
using(var conn = Create()) {
{ Assert.Throws(typeof(ArgumentNullException), delegate {
var raw = conn.GetDatabase(1); IDatabase raw = null;
var prefixed = raw.WithKeyPrefix(prefix);
var foo = raw.WithKeyPrefix("foo"); });
var foobar = foo.WithKeyPrefix("bar"); }
[Test]
string key = Me(); public void BasicSmokeTest()
{
string s = Guid.NewGuid().ToString(), t = Guid.NewGuid().ToString(); using(var conn = Create())
{
foo.StringSet(key, s); var raw = conn.GetDatabase(1);
var val = (string)foo.StringGet(key);
Assert.AreEqual(s, val); // fooBasicSmokeTest var foo = raw.WithKeyPrefix("foo");
var foobar = foo.WithKeyPrefix("bar");
foobar.StringSet(key, t);
val = (string)foobar.StringGet(key); string key = Me();
Assert.AreEqual(t, val); // foobarBasicSmokeTest
string s = Guid.NewGuid().ToString(), t = Guid.NewGuid().ToString();
val = (string)foo.StringGet("bar" + key);
Assert.AreEqual(t, val); // foobarBasicSmokeTest foo.StringSet(key, s);
var val = (string)foo.StringGet(key);
val = (string)raw.StringGet("foo" + key); Assert.AreEqual(s, val); // fooBasicSmokeTest
Assert.AreEqual(s, val); // fooBasicSmokeTest
foobar.StringSet(key, t);
val = (string)raw.StringGet("foobar" + key); val = (string)foobar.StringGet(key);
Assert.AreEqual(t, val); // foobarBasicSmokeTest Assert.AreEqual(t, val); // foobarBasicSmokeTest
}
} val = (string)foo.StringGet("bar" + key);
[Test] Assert.AreEqual(t, val); // foobarBasicSmokeTest
public void ConditionTest()
{ val = (string)raw.StringGet("foo" + key);
using(var conn = Create()) Assert.AreEqual(s, val); // fooBasicSmokeTest
{
var raw = conn.GetDatabase(2); val = (string)raw.StringGet("foobar" + key);
Assert.AreEqual(t, val); // foobarBasicSmokeTest
var foo = raw.WithKeyPrefix("tran:"); }
}
raw.KeyDelete("tran:abc"); [Test]
raw.KeyDelete("tran:i"); public void ConditionTest()
{
// execute while key exists using(var conn = Create())
raw.StringSet("tran:abc", "def"); {
var tran = foo.CreateTransaction(); var raw = conn.GetDatabase(2);
tran.AddCondition(Condition.KeyExists("abc"));
tran.StringIncrementAsync("i"); var foo = raw.WithKeyPrefix("tran:");
tran.Execute();
raw.KeyDelete("tran:abc");
int i = (int)raw.StringGet("tran:i"); raw.KeyDelete("tran:i");
Assert.AreEqual(1, i);
// execute while key exists
// repeat without key raw.StringSet("tran:abc", "def");
raw.KeyDelete("tran:abc"); var tran = foo.CreateTransaction();
tran = foo.CreateTransaction(); tran.AddCondition(Condition.KeyExists("abc"));
tran.AddCondition(Condition.KeyExists("abc")); tran.StringIncrementAsync("i");
tran.StringIncrementAsync("i"); tran.Execute();
tran.Execute();
int i = (int)raw.StringGet("tran:i");
i = (int)raw.StringGet("tran:i"); Assert.AreEqual(1, i);
Assert.AreEqual(1, i);
} // repeat without key
} raw.KeyDelete("tran:abc");
} tran = foo.CreateTransaction();
} tran.AddCondition(Condition.KeyExists("abc"));
tran.StringIncrementAsync("i");
tran.Execute();
i = (int)raw.StringGet("tran:i");
Assert.AreEqual(1, i);
}
}
}
}
...@@ -15,7 +15,8 @@ public sealed class WrapperBaseTests ...@@ -15,7 +15,8 @@ public sealed class WrapperBaseTests
private Mock<IDatabaseAsync> mock; private Mock<IDatabaseAsync> mock;
private WrapperBase<IDatabaseAsync> wrapper; private WrapperBase<IDatabaseAsync> wrapper;
[TestFixtureSetUp] //[TestFixtureSetUp]
[OneTimeSetUp]
public void Initialize() public void Initialize()
{ {
mock = new Mock<IDatabaseAsync>(); mock = new Mock<IDatabaseAsync>();
...@@ -258,10 +259,12 @@ public void KeyPersistAsync() ...@@ -258,10 +259,12 @@ public void KeyPersistAsync()
} }
[Test] [Test]
[ExpectedException(typeof(NotSupportedException))] //[ExpectedException(typeof(NotSupportedException))]
public void KeyRandomAsync() public void KeyRandomAsync()
{ {
wrapper.KeyRandomAsync(); Assert.Throws(typeof(NotSupportedException), delegate {
wrapper.KeyRandomAsync();
});
} }
[Test] [Test]
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
<packages> <packages>
<package id="BookSleeve" version="1.3.41" targetFramework="net45" /> <package id="BookSleeve" version="1.3.41" targetFramework="net45" />
<package id="Moq" version="4.2.1502.0911" targetFramework="net45" /> <package id="Moq" version="4.2.1502.0911" targetFramework="net45" />
<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
Copyright © 2002-2014 Charlie Poole
Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
Copyright © 2000-2002 Philip A. Craig
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment (see the following) in the product documentation is required.
Portions Copyright © 2002-2014 Charlie Poole or Copyright © 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov or Copyright © 2000-2002 Philip A. Craig
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
This diff is collapsed.
Copyright (c) 2015 Charlie Poole
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
NUnit 3.0 is based on earlier versions of NUnit, with Portions
Copyright (c) 2002-2014 Charlie Poole or
Copyright (c) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov or
Copyright (c) 2000-2002 Philip A. Craig
<?xml version="1.0" encoding="utf-8"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" /><Default Extension="nuspec" ContentType="application/octet" /><Default Extension="txt" ContentType="application/octet" /><Default Extension="dll" ContentType="application/octet" /><Default Extension="xml" ContentType="application/octet" /><Default Extension="psmdcp" ContentType="application/vnd.openxmlformats-package.core-properties+xml" /></Types>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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