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
private Mock<IBatch> mock;
private BatchWrapper wrapper;
[TestFixtureSetUp]
//[TestFixtureSetUp]
[OneTimeSetUpAttribute]
public void Initialize()
{
mock = new Mock<IBatch>();
......
This diff is collapsed.
......@@ -125,7 +125,7 @@ public void ClientName()
}
[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()
{
using (var muxer = Create(allowAdmin: true, disabledCommands: new[] { "config", "info" }))
......
......@@ -15,7 +15,8 @@ public sealed class DatabaseWrapperTests
private Mock<IDatabase> mock;
private DatabaseWrapper wrapper;
[TestFixtureSetUp]
//[TestFixtureSetUp]
[OneTimeSetUp]
public void Initialize()
{
mock = new Mock<IDatabase>();
......@@ -289,10 +290,10 @@ public void KeyPersist()
}
[Test]
[ExpectedException(typeof(NotSupportedException))]
//[ExpectedException(typeof(NotSupportedException))]
public void KeyRandom()
{
wrapper.KeyRandom();
Assert.Throws(typeof(NotSupportedException), delegate { wrapper.KeyRandom(); });
}
[Test]
......
......@@ -23,15 +23,23 @@ public void UnkonwnKeywordHandling_Ignore()
{
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()
{
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()
{
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()
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()
{
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);
slave.FlushDatabase();
}
Exception ex = Assert.Throws(typeof(RedisCommandException), delegate {
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);
slave.FlushDatabase();
}
});
Assert.That(ex.Message.Equals("Command cannot be issued to a slave: FLUSHDB"));
}
[Test]
......
This diff is collapsed.
......@@ -68,14 +68,17 @@ public void Connect()
[Test]
[TestCase("wrong")]
[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)
{
SetExpectedAmbientFailureCount(-1);
using (var server = Create(password: password, checkConnect: false))
{
server.GetDatabase().Ping();
}
Exception ex = Assert.Throws(typeof(RedisConnectionException), delegate {
SetExpectedAmbientFailureCount(-1);
using (var server = Create(password: password, checkConnect: false))
{
server.GetDatabase().Ping();
}
});
Assert.That(ex.Message.Equals("No connection is available to service this operation: PING"));
}
}
}
......@@ -6,7 +6,7 @@
namespace StackExchange.Redis.Tests
{
[TestFixture, Ignore]
[TestFixture, Ignore("reason?")]
public class Sentinel
{
// TODO fill in these constants before running tests
......@@ -100,7 +100,7 @@ public void SentinelSlavesTest()
}
}
[Test, Ignore]
[Test, Ignore("reason?")]
public void SentinelFailoverTest()
{
Server.SentinelFailover(ServiceName);
......
......@@ -66,9 +66,9 @@
<HintPath>..\packages\Moq.4.2.1502.0911\lib\net40\Moq.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="nunit.framework, Version=2.6.4.14350, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
<Reference Include="nunit.framework, Version=3.0.5715.30856, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.0.0-beta-5\lib\net45\nunit.framework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
......
......@@ -11,7 +11,8 @@ public sealed class TransactionWrapperTests
private Mock<ITransaction> mock;
private TransactionWrapper wrapper;
[TestFixtureSetUp]
//[TestFixtureSetUp]
[OneTimeSetUp]
public void Initialize()
{
mock = new Mock<ITransaction>();
......
using System;
using NUnit.Framework;
using StackExchange.Redis.KeyspaceIsolation;
namespace StackExchange.Redis.Tests
{
[TestFixture]
public class WithKeyPrefixTests : TestBase
{
[Test]
public void BlankPrefixYieldsSame_Bytes()
{
using (var conn = Create())
{
var raw = conn.GetDatabase(1);
var prefixed = raw.WithKeyPrefix(new byte[0]);
Assert.AreSame(raw, prefixed);
}
}
[Test]
public void BlankPrefixYieldsSame_String()
{
using (var conn = Create())
{
var raw = conn.GetDatabase(1);
var prefixed = raw.WithKeyPrefix("");
Assert.AreSame(raw, prefixed);
}
}
[Test, ExpectedException(typeof(ArgumentNullException))]
public void NullPrefixIsError_Bytes()
{
using (var conn = Create())
{
var raw = conn.GetDatabase(1);
var prefixed = raw.WithKeyPrefix((byte[])null);
}
}
[Test, ExpectedException(typeof(ArgumentNullException))]
public void NullPrefixIsError_String()
{
using (var conn = Create())
{
var raw = conn.GetDatabase(1);
var prefixed = raw.WithKeyPrefix((string)null);
}
}
[Test, ExpectedException(typeof(ArgumentNullException))]
[TestCase("abc")]
[TestCase("")]
[TestCase(null)]
public void NullDatabaseIsError(string prefix)
{
IDatabase raw = null;
var prefixed = raw.WithKeyPrefix(prefix);
}
[Test]
public void BasicSmokeTest()
{
using(var conn = Create())
{
var raw = conn.GetDatabase(1);
var foo = raw.WithKeyPrefix("foo");
var foobar = foo.WithKeyPrefix("bar");
string key = Me();
string s = Guid.NewGuid().ToString(), t = Guid.NewGuid().ToString();
foo.StringSet(key, s);
var val = (string)foo.StringGet(key);
Assert.AreEqual(s, val); // fooBasicSmokeTest
foobar.StringSet(key, t);
val = (string)foobar.StringGet(key);
Assert.AreEqual(t, val); // foobarBasicSmokeTest
val = (string)foo.StringGet("bar" + key);
Assert.AreEqual(t, val); // foobarBasicSmokeTest
val = (string)raw.StringGet("foo" + key);
Assert.AreEqual(s, val); // fooBasicSmokeTest
val = (string)raw.StringGet("foobar" + key);
Assert.AreEqual(t, val); // foobarBasicSmokeTest
}
}
[Test]
public void ConditionTest()
{
using(var conn = Create())
{
var raw = conn.GetDatabase(2);
var foo = raw.WithKeyPrefix("tran:");
raw.KeyDelete("tran:abc");
raw.KeyDelete("tran:i");
// execute while key exists
raw.StringSet("tran:abc", "def");
var tran = foo.CreateTransaction();
tran.AddCondition(Condition.KeyExists("abc"));
tran.StringIncrementAsync("i");
tran.Execute();
int i = (int)raw.StringGet("tran: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);
}
}
}
}
using System;
using NUnit.Framework;
using StackExchange.Redis.KeyspaceIsolation;
namespace StackExchange.Redis.Tests
{
[TestFixture]
public class WithKeyPrefixTests : TestBase
{
[Test]
public void BlankPrefixYieldsSame_Bytes()
{
using (var conn = Create())
{
var raw = conn.GetDatabase(1);
var prefixed = raw.WithKeyPrefix(new byte[0]);
Assert.AreSame(raw, prefixed);
}
}
[Test]
public void BlankPrefixYieldsSame_String()
{
using (var conn = Create())
{
var raw = conn.GetDatabase(1);
var prefixed = raw.WithKeyPrefix("");
Assert.AreSame(raw, prefixed);
}
}
[Test]
//, ExpectedException(typeof(ArgumentNullException))]
public void NullPrefixIsError_Bytes()
{
Assert.Throws(typeof(ArgumentNullException), delegate {
using (var conn = Create())
{
var raw = conn.GetDatabase(1);
var prefixed = raw.WithKeyPrefix((byte[])null);
}
});
}
[Test]
//, ExpectedException(typeof(ArgumentNullException))]
public void NullPrefixIsError_String()
{
Assert.Throws(typeof(ArgumentNullException), delegate {
using (var conn = Create())
{
var raw = conn.GetDatabase(1);
var prefixed = raw.WithKeyPrefix((string)null);
}
});
}
[Test]
//, ExpectedException(typeof(ArgumentNullException))]
[TestCase("abc")]
[TestCase("")]
[TestCase(null)]
public void NullDatabaseIsError(string prefix)
{
Assert.Throws(typeof(ArgumentNullException), delegate {
IDatabase raw = null;
var prefixed = raw.WithKeyPrefix(prefix);
});
}
[Test]
public void BasicSmokeTest()
{
using(var conn = Create())
{
var raw = conn.GetDatabase(1);
var foo = raw.WithKeyPrefix("foo");
var foobar = foo.WithKeyPrefix("bar");
string key = Me();
string s = Guid.NewGuid().ToString(), t = Guid.NewGuid().ToString();
foo.StringSet(key, s);
var val = (string)foo.StringGet(key);
Assert.AreEqual(s, val); // fooBasicSmokeTest
foobar.StringSet(key, t);
val = (string)foobar.StringGet(key);
Assert.AreEqual(t, val); // foobarBasicSmokeTest
val = (string)foo.StringGet("bar" + key);
Assert.AreEqual(t, val); // foobarBasicSmokeTest
val = (string)raw.StringGet("foo" + key);
Assert.AreEqual(s, val); // fooBasicSmokeTest
val = (string)raw.StringGet("foobar" + key);
Assert.AreEqual(t, val); // foobarBasicSmokeTest
}
}
[Test]
public void ConditionTest()
{
using(var conn = Create())
{
var raw = conn.GetDatabase(2);
var foo = raw.WithKeyPrefix("tran:");
raw.KeyDelete("tran:abc");
raw.KeyDelete("tran:i");
// execute while key exists
raw.StringSet("tran:abc", "def");
var tran = foo.CreateTransaction();
tran.AddCondition(Condition.KeyExists("abc"));
tran.StringIncrementAsync("i");
tran.Execute();
int i = (int)raw.StringGet("tran: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
private Mock<IDatabaseAsync> mock;
private WrapperBase<IDatabaseAsync> wrapper;
[TestFixtureSetUp]
//[TestFixtureSetUp]
[OneTimeSetUp]
public void Initialize()
{
mock = new Mock<IDatabaseAsync>();
......@@ -258,10 +259,12 @@ public void KeyPersistAsync()
}
[Test]
[ExpectedException(typeof(NotSupportedException))]
//[ExpectedException(typeof(NotSupportedException))]
public void KeyRandomAsync()
{
wrapper.KeyRandomAsync();
Assert.Throws(typeof(NotSupportedException), delegate {
wrapper.KeyRandomAsync();
});
}
[Test]
......
......@@ -2,5 +2,5 @@
<packages>
<package id="BookSleeve" version="1.3.41" 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>
\ 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