Commit 5b5d43cc authored by Marc Gravell's avatar Marc Gravell

Add BookSleeve test suite; so far Strings+Issues migrated (rest commented)

parent a2add23c
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
\ No newline at end of file
//using NUnit.Framework;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//namespace Tests
//{
// [TestFixture]
// public class Batches
// {
// [Test]
// public void TestBatchNotSent()
// {
// using (var conn = Config.GetUnsecuredConnection())
// {
// conn.Keys.Remove(0, "batch");
// conn.Strings.Set(0, "batch", "batch-not-sent");
// var tasks = new List<Task>();
// using (var batch = conn.CreateBatch())
// {
// tasks.Add(batch.Keys.Remove(0, "batch"));
// tasks.Add(batch.Sets.Add(0, "batch", "a"));
// tasks.Add(batch.Sets.Add(0, "batch", "b"));
// tasks.Add(batch.Sets.Add(0, "batch", "c"));
// }
// Assert.AreEqual("batch-not-sent", conn.Wait(conn.Strings.GetString(0, "batch")));
// }
// }
// [Test]
// public void TestBatchSentTogether()
// {
// TestBatchSent(true);
// }
// [Test]
// public void TestBatchSentApart()
// {
// TestBatchSent(false);
// }
// private void TestBatchSent(bool together)
// {
// using (var conn = Config.GetUnsecuredConnection())
// {
// conn.Keys.Remove(0, "batch");
// conn.Strings.Set(0, "batch", "batch-sent");
// var tasks = new List<Task>();
// using (var batch = conn.CreateBatch())
// {
// tasks.Add(batch.Keys.Remove(0, "batch"));
// tasks.Add(batch.Sets.Add(0, "batch", "a"));
// tasks.Add(batch.Sets.Add(0, "batch", "b"));
// tasks.Add(batch.Sets.Add(0, "batch", "c"));
// batch.Send(together);
// }
// var result = conn.Sets.GetAllString(0, "batch");
// tasks.Add(result);
// Task.WhenAll(tasks.ToArray());
// var arr = result.Result;
// Array.Sort(arr);
// Assert.AreEqual(3, arr.Length);
// Assert.AreEqual("a", arr[0]);
// Assert.AreEqual("b", arr[1]);
// Assert.AreEqual("c", arr[2]);
// }
// }
// }
//}
using System;
using System.Net.Sockets;
using NUnit.Framework;
using System.Threading;
using System.Diagnostics;
using System.Threading.Tasks;
using System.IO;
using StackExchange.Redis;
namespace Tests
{
[TestFixture(Description = "Validates that the test environment is configured and responding")]
public class Config
{
public static string CreateUniqueName()
{
return Guid.NewGuid().ToString("N");
}
internal static IServer GetServer(ConnectionMultiplexer conn)
{
return conn.GetServer(conn.GetEndPoints()[0]);
}
static readonly SocketManager socketManager = new SocketManager();
static Config()
{
TaskScheduler.UnobservedTaskException += (sender, args) =>
{
Trace.WriteLine(args.Exception, "UnobservedTaskException");
args.SetObserved();
};
}
public const string LocalHost = "127.0.0.1"; //"192.168.0.10"; //"127.0.0.1";
public const string RemoteHost = "ubuntu";
const int unsecuredPort = 6379, securedPort = 6381,
clusterPort0 = 7000, clusterPort1 = 7001, clusterPort2 = 7002;
#if CLUSTER
internal static RedisCluster GetCluster(TextWriter log = null)
{
string clusterConfiguration =
RemoteHost + ":" + clusterPort0 + "," +
RemoteHost + ":" + clusterPort1 + "," +
RemoteHost + ":" + clusterPort2;
return RedisCluster.Connect(clusterConfiguration, log);
}
#endif
//const int unsecuredPort = 6380, securedPort = 6381;
internal static ConnectionMultiplexer GetRemoteConnection(bool open = true, bool allowAdmin = false, bool waitForOpen = false, int syncTimeout = 5000, int ioTimeout = 5000)
{
return GetConnection(RemoteHost, unsecuredPort, open, allowAdmin, waitForOpen, syncTimeout, ioTimeout);
}
private static ConnectionMultiplexer GetConnection(string host, int port, bool open = true, bool allowAdmin = false, bool waitForOpen = false, int syncTimeout = 5000, int ioTimeout = 5000)
{
var options = new ConfigurationOptions
{
EndPoints = { { host, port } },
AllowAdmin = allowAdmin,
SyncTimeout = syncTimeout,
SocketManager = socketManager
};
var conn = ConnectionMultiplexer.Connect(options);
conn.InternalError += (s, args) =>
{
Trace.WriteLine(args.Exception.Message, args.Origin);
};
if (open)
{
if (waitForOpen) conn.GetDatabase().Ping();
}
return conn;
}
internal static ConnectionMultiplexer GetUnsecuredConnection(bool open = true, bool allowAdmin = false, bool waitForOpen = false, int syncTimeout = 5000, int ioTimeout = 5000)
{
return GetConnection(LocalHost, unsecuredPort, open, allowAdmin, waitForOpen, syncTimeout, ioTimeout);
}
internal static ConnectionMultiplexer GetSecuredConnection(bool open = true)
{
var options = new ConfigurationOptions
{
EndPoints = { { LocalHost, securedPort } },
Password = "changeme",
SyncTimeout = 6000,
SocketManager = socketManager
};
var conn = ConnectionMultiplexer.Connect(options);
conn.InternalError += (s, args) =>
{
Trace.WriteLine(args.Exception.Message, args.Origin);
};
return conn;
}
internal static RedisFeatures GetFeatures(ConnectionMultiplexer muxer)
{
return GetServer(muxer).Features;
}
[Test]
public void CanOpenUnsecuredConnection()
{
using (var conn = GetUnsecuredConnection(false))
{
var server = GetServer(conn);
server.Ping();
}
}
[Test]
public void CanOpenSecuredConnection()
{
using (var conn = GetSecuredConnection(false))
{
var server = GetServer(conn);
server.Ping();
}
}
[Test, ExpectedException(typeof(SocketException))]
public void CanNotOpenNonsenseConnection_IP()
{
using (var conn = ConnectionMultiplexer.Connect(Config.LocalHost + ":6500"))
{
}
}
[Test, ExpectedException(typeof(SocketException))]
public void CanNotOpenNonsenseConnection_DNS()
{
using (var conn = ConnectionMultiplexer.Connect("doesnot.exist.ds.aasd981230d.com:6500"))
{
}
}
internal static void AssertNearlyEqual(double x, double y)
{
if (Math.Abs(x - y) > 0.00001) Assert.AreEqual(x, y);
}
}
}
\ No newline at end of file
This diff is collapsed.
//using BookSleeve;
//using NUnit.Framework;
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;
//namespace Tests
//{
// [TestFixture]
// public class Constraints
// {
// [Test]
// public void TestManualIncr()
// {
// using (var conn = Config.GetUnsecuredConnection(syncTimeout: 120000)) // big timeout while debugging
// {
// for (int i = 0; i < 200; i++)
// {
// conn.Keys.Remove(0, "foo");
// Assert.AreEqual(1, conn.Wait(ManualIncr(conn, 0, "foo")));
// Assert.AreEqual(2, conn.Wait(ManualIncr(conn, 0, "foo")));
// Assert.AreEqual(2, conn.Wait(conn.Strings.GetInt64(0, "foo")));
// }
// }
// }
// public async Task<long?> ManualIncr(RedisConnection connection, int db, string key)
// {
// var oldVal = await connection.Strings.GetInt64(db, key).SafeAwaitable();
// var newVal = (oldVal ?? 0) + 1;
// using (var tran = connection.CreateTransaction())
// { // check hasn't changed
//#pragma warning disable 4014
// tran.AddCondition(Condition.KeyEquals(db, key, oldVal));
// tran.Strings.Set(db, key, newVal);
//#pragma warning restore 4014
// if (!await tran.Execute().SafeAwaitable()) return null; // aborted
// return newVal;
// }
// }
// }
//}
This diff is collapsed.
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tests.Issues
{
[TestFixture]
public class Issue10
{
[Test]
public void Execute()
{
using (var muxer = Config.GetUnsecuredConnection())
{
const int DB = 5;
const string Key = "issue-10-list";
var conn = muxer.GetDatabase(DB);
conn.KeyDeleteAsync(Key); // contents: nil
conn.ListLeftPushAsync(Key, "abc"); // "abc"
conn.ListLeftPushAsync(Key, "def"); // "def", "abc"
conn.ListLeftPushAsync(Key, "ghi"); // "ghi", "def", "abc",
conn.ListSetByIndexAsync(Key, 1, "jkl"); // "ghi", "jkl", "abc"
var contents = conn.Wait(conn.ListRangeAsync(Key, 0, -1));
Assert.AreEqual(3, contents.Length);
Assert.AreEqual("ghi", (string)contents[0]);
Assert.AreEqual("jkl", (string)contents[1]);
Assert.AreEqual("abc", (string)contents[2]);
}
}
}
}
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using NUnit.Framework;
namespace Tests.Issues
{
[TestFixture]
public class Massive_Delete
{
[TestFixtureSetUp]
public void Init()
{
using (var muxer = Config.GetUnsecuredConnection(allowAdmin: true))
{
Config.GetServer(muxer).FlushDatabase(db);
Task last = null;
var conn = muxer.GetDatabase(db);
for (int i = 0; i < 100000; i++)
{
string key = "key" + i;
conn.StringSetAsync(key, key);
last = conn.SetAddAsync(todoKey, key);
}
conn.Wait(last);
}
}
const int db = 4;
const string todoKey = "todo";
[Test]
public void ExecuteMassiveDelete()
{
var watch = Stopwatch.StartNew();
using (var muxer = Config.GetUnsecuredConnection())
using (var throttle = new SemaphoreSlim(1))
{
var conn = muxer.GetDatabase(db);
var originallyTask = conn.SetLengthAsync(todoKey);
int keepChecking = 1;
Task last = null;
while (Thread.VolatileRead(ref keepChecking) == 1)
{
throttle.Wait(); // acquire
conn.SetPopAsync(todoKey).ContinueWith(task =>
{
throttle.Release();
if (task.IsCompleted)
{
if ((string)task.Result == null)
{
Thread.VolatileWrite(ref keepChecking, 0);
}
else
{
last = conn.KeyDeleteAsync((string)task.Result);
}
}
});
}
if (last != null)
{
conn.Wait(last);
}
watch.Stop();
long originally = conn.Wait(originallyTask),
remaining = conn.SetLength(todoKey);
Console.WriteLine("From {0} to {1}; {2}ms", originally, remaining,
watch.ElapsedMilliseconds);
var counters = Config.GetServer(muxer).GetCounters();
Console.WriteLine("Completions: {0} sync, {1} async", counters.Interactive.CompletedSynchronously, counters.Interactive.CompletedAsynchronously);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.Diagnostics;
using StackExchange.Redis;
namespace Tests.Issues
{
[TestFixture]
public class SO10504853
{
[Test]
public void LoopLotsOfTrivialStuff()
{
Trace.WriteLine("### init");
using (var muxer = Config.GetUnsecuredConnection())
{
var conn = muxer.GetDatabase(0);
conn.KeyDelete("lots-trivial");
}
const int COUNT = 2;
for (int i = 0; i < COUNT; i++)
{
Trace.WriteLine("### incr:" + i);
using (var muxer = Config.GetUnsecuredConnection())
{
var conn = muxer.GetDatabase(0);
Assert.AreEqual(i + 1, conn.StringIncrement("lots-trivial"));
}
}
Trace.WriteLine("### close");
using (var muxer = Config.GetUnsecuredConnection())
{
var conn = muxer.GetDatabase(0);
Assert.AreEqual(COUNT, (long)conn.StringGet("lots-trivial"));
}
}
[Test]
public void ExecuteWithEmptyStartingPoint()
{
using (var muxer = Config.GetUnsecuredConnection())
{
var conn = muxer.GetDatabase(0);
var task = new { priority = 3 };
conn.KeyDeleteAsync("item:1");
conn.HashSetAsync("item:1", "something else", "abc");
conn.HashSetAsync("item:1", "priority", task.priority.ToString());
var taskResult = conn.HashGetAsync("item:1", "priority");
conn.Wait(taskResult);
var priority = Int32.Parse(taskResult.Result);
Assert.AreEqual(3, priority);
}
}
[Test, ExpectedException(typeof(RedisServerException), ExpectedMessage = "WRONGTYPE Operation against a key holding the wrong kind of value")]
public void ExecuteWithNonHashStartingPoint()
{
using (var muxer = Config.GetUnsecuredConnection())
{
var conn = muxer.GetDatabase(0);
var task = new { priority = 3 };
conn.KeyDeleteAsync("item:1");
conn.StringSetAsync("item:1", "not a hash");
conn.HashSetAsync("item:1", "priority", task.priority.ToString());
var taskResult = conn.HashGetAsync("item:1", "priority");
try
{
conn.Wait(taskResult);
Assert.Fail();
} catch(AggregateException ex)
{
throw ex.InnerExceptions[0];
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using StackExchange.Redis;
namespace Tests.Issues
{
[TestFixture]
public class SO10825542
{
[Test]
public void Execute()
{
using (var muxer = Config.GetUnsecuredConnection())
{
var key = "somekey1";
var con = muxer.GetDatabase(1);
// set the field value and expiration
con.HashSetAsync(key, "field1", Encoding.UTF8.GetBytes("hello world"));
con.KeyExpireAsync(key, TimeSpan.FromSeconds(7200));
con.HashSetAsync(key, "field2", "fooobar");
var task = con.HashGetAllAsync(key);
con.Wait(task);
Assert.AreEqual(2, task.Result.Length);
var dict = task.Result.ToStringDictionary();
Assert.AreEqual("hello world", dict["field1"]);
Assert.AreEqual("fooobar", dict["field2"]);
}
}
}
}
using System;
using NUnit.Framework;
namespace Tests.Issues
{
[TestFixture]
public class SO11766033
{
[Test]
public void TestNullString()
{
const int db = 3;
using (var muxer = Config.GetUnsecuredConnection(true))
{
var redis = muxer.GetDatabase(db);
string expectedTestValue = null;
var uid = Config.CreateUniqueName();
redis.StringSetAsync(uid, "abc");
redis.StringSetAsync(uid, expectedTestValue);
string testValue = redis.StringGet(uid);
Assert.IsNull(testValue);
}
}
[Test]
public void TestEmptyString()
{
const int db = 3;
using (var muxer = Config.GetUnsecuredConnection(true))
{
var redis = muxer.GetDatabase(db);
string expectedTestValue = "";
var uid = Config.CreateUniqueName();
redis.StringSetAsync(uid, expectedTestValue);
string testValue = redis.StringGet(uid);
Assert.AreEqual(expectedTestValue, testValue);
}
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{97B45B3A-34DB-43C3-A979-37F217390142}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MigratedBookSleeveTestSuite</RootNamespace>
<AssemblyName>MigratedBookSleeveTestSuite</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Batches.cs" />
<Compile Include="Config.cs" />
<Compile Include="Connection.cs" />
<Compile Include="Constraints.cs" />
<Compile Include="Hashes.cs" />
<Compile Include="Issues\Issue10.cs" />
<Compile Include="Issues\Massive Delete.cs" />
<Compile Include="Issues\SO10504853.cs" />
<Compile Include="Issues\SO10825542.cs" />
<Compile Include="Issues\SO11766033.cs" />
<Compile Include="Keys.cs" />
<Compile Include="Lists.cs" />
<Compile Include="Locking.cs" />
<Compile Include="Performance.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PubSub.cs" />
<Compile Include="redis-sharp.cs" />
<Compile Include="Scripting.cs" />
<Compile Include="Server.cs" />
<Compile Include="Sets.cs" />
<Compile Include="SortedSets.cs" />
<Compile Include="Strings.cs" />
<Compile Include="Transactions.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StackExchange.Redis\StackExchange.Redis.csproj">
<Project>{7cec07f2-8c03-4c42-b048-738b215824c1}</Project>
<Name>StackExchange.Redis</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
\ No newline at end of file
//using System;
//using System.Diagnostics;
//using System.Text;
//using System.Threading.Tasks;
//using NUnit.Framework;
//namespace Tests
//{
// [TestFixture]
// public class Performance
// {
// [Test]
// public void VerifyPerformanceImprovement()
// {
// int asyncTimer, sync, op = 0, asyncFaF, syncFaF;
// using (var conn = Config.GetUnsecuredConnection())
// {
// // do these outside the timings, just to ensure the core methods are JITted etc
// for (int db = 0; db < 5; db++ )
// conn.Keys.Remove(db, "perftest");
// var timer = Stopwatch.StartNew();
// for (int i = 0; i < 100; i++)
// {
// // want to test multiplex scenario; test each db, but to make it fair we'll
// // do in batches of 10 on each
// for (int db = 0; db < 5; db++)
// for (int j = 0; j < 10; j++)
// conn.Strings.Increment(db, "perftest");
// }
// asyncFaF = (int)timer.ElapsedMilliseconds;
// Task<string>[] final = new Task<string>[5];
// for (int db = 0; db < 5; db++)
// final[db] = conn.Strings.GetString(db, "perftest");
// conn.WaitAll(final);
// timer.Stop();
// asyncTimer = (int)timer.ElapsedMilliseconds;
// Console.WriteLine("async to completion (local): {0}ms", timer.ElapsedMilliseconds);
// for (int db = 0; db < 5; db++)
// Assert.AreEqual("1000", final[db].Result, "async, db:" + db);
// }
// using (var conn = new Redis(Config.LocalHost, 6379))
// {
// // do these outside the timings, just to ensure the core methods are JITted etc
// for (int db = 0; db < 5; db++) {
// conn.Db = db;
// conn.Remove("perftest");
// }
// var timer = Stopwatch.StartNew();
// for (int i = 0; i < 100; i++)
// {
// // want to test multiplex scenario; test each db, but to make it fair we'll
// // do in batches of 10 on each
// for (int db = 0; db < 5; db++) {
// conn.Db = db;
// op++;
// for (int j = 0; j < 10; j++) {
// conn.Increment("perftest");
// op++;
// }
// }
// }
// syncFaF = (int)timer.ElapsedMilliseconds;
// string[] final = new string[5];
// for (int db = 0; db < 5; db++) {
// conn.Db = db;
// final[db] = Encoding.ASCII.GetString(conn.Get("perftest"));
// }
// timer.Stop();
// sync = (int)timer.ElapsedMilliseconds;
// Console.WriteLine("sync to completion (local): {0}ms", timer.ElapsedMilliseconds);
// for (int db = 0; db < 5; db++)
// Assert.AreEqual("1000", final[db], "async, db:" + db);
// }
// int effectiveAsync = ((10 * asyncTimer) + 3) / 10;
// int effectiveSync = ((10 * sync) + (op * 3)) / 10;
// Console.WriteLine("async to completion with assumed 0.3ms LAN latency: " + effectiveAsync);
// Console.WriteLine("sync to completion with assumed 0.3ms LAN latency: " + effectiveSync);
// Console.WriteLine("fire-and-forget: {0}ms sync vs {1}ms async ", syncFaF, asyncFaF);
// Assert.Less(effectiveAsync, effectiveSync, "Everything");
// Assert.Less(asyncFaF, syncFaF, "Fire and Forget");
// }
// }
//}
//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using NUnit.Framework;
//using System.Reflection;
//using System.Threading.Tasks;
//namespace Tests
//{
// class Program
// {
// static void Main()
// {
// try
// {
// Main2();
// }
// catch (Exception ex)
// {
// Console.WriteLine();
// Console.WriteLine("CRAZY ERRORS: " + ex);
// }
// finally
// {
// Console.WriteLine("Press any key to exit");
// Console.ReadKey();
// }
// }
// static void Main2() {
// // why is this here? because some dumbass forgot to install a decent test-runner before going to the airport
// var epicFail = new List<string>();
// var testTypes = from type in typeof(Program).Assembly.GetTypes()
// where Attribute.IsDefined(type, typeof(TestFixtureAttribute))
// && !Attribute.IsDefined(type, typeof(IgnoreAttribute))
// let methods = type.GetMethods()
// select new
// {
// Type = type,
// Methods = methods,
// ActiveMethods = methods.Where(x => Attribute.IsDefined(x, typeof(ActiveTestAttribute))).ToArray(),
// Setup = methods.SingleOrDefault(x => Attribute.IsDefined(x, typeof(TestFixtureSetUpAttribute))),
// TearDown = methods.SingleOrDefault(x => Attribute.IsDefined(x, typeof(TestFixtureTearDownAttribute)))
// };
// int pass = 0, fail = 0;
// bool activeOnly = testTypes.SelectMany(x => x.ActiveMethods).Any();
// TaskScheduler.UnobservedTaskException += (sender, args) =>
// {
// args.SetObserved();
// //if (args.Exception is AggregateException)
// //{
// // foreach (var ex in ((AggregateException)args.Exception).InnerExceptions)
// // {
// // Console.WriteLine(ex.Message);
// // }
// //}
// //else
// //{
// // Console.WriteLine(args.Exception.Message);
// //}
// };
// foreach (var type in testTypes)
// {
// var tests = (from method in (activeOnly ? type.ActiveMethods : type.Methods)
// where Attribute.IsDefined(method, typeof(TestAttribute))
// && !Attribute.IsDefined(method, typeof(IgnoreAttribute))
// select method).ToArray();
// if (tests.Length == 0) continue;
// Console.WriteLine(type.Type.FullName);
// object obj;
// try
// {
// obj = Activator.CreateInstance(type.Type);
// if (obj == null) throw new InvalidOperationException("the world has gone mad");
// }
// catch (Exception ex)
// {
// Console.WriteLine(ex.Message);
// continue;
// }
// using (obj as IDisposable)
// {
// if (type.Setup != null)
// {
// try { type.Setup.Invoke(obj, null); }
// catch (Exception ex)
// {
// Console.WriteLine("Test fixture startup failed: " + ex.Message);
// fail++;
// epicFail.Add(type.Setup.DeclaringType.FullName + "." + type.Setup.Name);
// continue;
// }
// }
// foreach (var test in tests)
// {
// var expectedFail = Attribute.GetCustomAttribute(test, typeof(ExpectedExceptionAttribute)) as ExpectedExceptionAttribute;
// Console.Write(test.Name + ": ");
// Exception err = null;
// try
// {
// int count = 1;
// if (activeOnly)
// {
// var ata = test.GetCustomAttribute(typeof(ActiveTestAttribute)) as ActiveTestAttribute;
// if (ata != null) count = ata.Count;
// }
// while (count-- > 0)
// {
// test.Invoke(obj, null);
// }
// }
// catch (TargetInvocationException ex)
// {
// err = ex.InnerException;
// }
// catch (Exception ex)
// {
// err = ex;
// }
// if (err is AggregateException && ((AggregateException)err).InnerExceptions.Count == 1)
// {
// 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)
// {
// Console.WriteLine("pass");
// pass++;
// }
// else
// {
// Console.WriteLine(err.Message);
// fail++;
// epicFail.Add(test.DeclaringType.FullName + "." + test.Name);
// }
// }
// if (type.TearDown != null)
// {
// try { type.TearDown.Invoke(obj, null); }
// catch (Exception ex)
// {
// Console.WriteLine("Test fixture teardown failed: " + ex.Message);
// fail++;
// epicFail.Add(type.TearDown.DeclaringType.FullName + "." + type.TearDown.Name);
// }
// }
// }
// }
// Console.WriteLine("Passed: {0}; Failed: {1}", pass, fail);
// foreach (var msg in epicFail) Console.WriteLine(msg);
//#if DEBUG
// Console.WriteLine();
// Console.WriteLine("Callbacks: {0:###,###,##0} sync, {1:###,###,##0} async",
// BookSleeve.RedisConnectionBase.AllSyncCallbacks, BookSleeve.RedisConnectionBase.AllAsyncCallbacks);
//#endif
// }
// }
//}
//[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
//public sealed class ActiveTestAttribute : Attribute {
// private readonly int count;
// public int Count { get { return count; } }
// public ActiveTestAttribute() : this(1) { }
// public ActiveTestAttribute(int count) { this.count = count; }
//}
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MigratedBookSleeveTestSuite")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MigratedBookSleeveTestSuite")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("350d3b30-78dd-4b74-a76d-bb593a05e8d1")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit" version="2.6.3" targetFramework="net45" />
</packages>
\ No newline at end of file
This diff is collapsed.
......@@ -46,6 +46,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Docs", "Docs\Docs.csproj",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicTest", "BasicTest\BasicTest.csproj", "{BE213DFB-5334-4441-B975-0DBCFD5F5A73}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MigratedBookSleeveTestSuite", "MigratedBookSleeveTestSuite\MigratedBookSleeveTestSuite.csproj", "{97B45B3A-34DB-43C3-A979-37F217390142}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -94,6 +96,14 @@ Global
{BE213DFB-5334-4441-B975-0DBCFD5F5A73}.Release|Any CPU.Build.0 = Release|Any CPU
{BE213DFB-5334-4441-B975-0DBCFD5F5A73}.Verbose|Any CPU.ActiveCfg = Release|Any CPU
{BE213DFB-5334-4441-B975-0DBCFD5F5A73}.Verbose|Any CPU.Build.0 = Release|Any CPU
{97B45B3A-34DB-43C3-A979-37F217390142}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97B45B3A-34DB-43C3-A979-37F217390142}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97B45B3A-34DB-43C3-A979-37F217390142}.Log Output|Any CPU.ActiveCfg = Release|Any CPU
{97B45B3A-34DB-43C3-A979-37F217390142}.Log Output|Any CPU.Build.0 = Release|Any CPU
{97B45B3A-34DB-43C3-A979-37F217390142}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97B45B3A-34DB-43C3-A979-37F217390142}.Release|Any CPU.Build.0 = Release|Any CPU
{97B45B3A-34DB-43C3-A979-37F217390142}.Verbose|Any CPU.ActiveCfg = Release|Any CPU
{97B45B3A-34DB-43C3-A979-37F217390142}.Verbose|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
<?xml version="1.0" encoding="utf-8"?>
<repositories>
<repository path="..\MigratedBookSleeveTestSuite\packages.config" />
<repository path="..\StackExchange.Redis.Tests\packages.config" />
</repositories>
\ 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