Permalink
Browse files

Ported PerformanceTests to XUnit

  • Loading branch information...
1 parent ecfb7bc commit 1de952037e63c6bb9af98cc0c8a53a9da5e55295 @Danthar Danthar committed Sep 26, 2016
@@ -5,11 +5,11 @@
using System.Text;
using MBrace.FsPickler;
using Microsoft.FSharp.Collections;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Xunit;
+using Xunit.Sdk;
namespace Wire.PerformanceTests
{
- [TestClass]
public class SpeedAndSizeTests
{
[Serializable]
@@ -31,7 +31,7 @@ public class Poco
public string Name { get; set; }
}
- [TestMethod]
+ [Fact]
public void TestPocoArray()
{
var arr = new Poco[200];
@@ -47,13 +47,13 @@ public void TestPocoArray()
Test(arr);
}
- [TestMethod]
+ [Fact]
public void TestDateTime()
{
Test(DateTime.Now);
}
- [TestMethod]
+ [Fact]
public void TestDateTimeArray()
{
var arr = new DateTime[200];
@@ -65,7 +65,7 @@ public void TestDateTimeArray()
Test(arr);
}
- [TestMethod]
+ [Fact]
public void TestGuidArray()
{
var arr = new Guid[200];
@@ -77,7 +77,7 @@ public void TestGuidArray()
Test(arr);
}
- [TestMethod]
+ [Fact]
public void TestIntArray()
{
var arr = new int[1000];
@@ -89,14 +89,14 @@ public void TestIntArray()
Test(arr);
}
- [TestMethod]
+ [Fact]
public void TestStringShort()
{
Test("hello");
}
- [TestMethod]
+ [Fact]
public void TestStringLong()
{
var sb = new StringBuilder();
@@ -111,7 +111,7 @@ public void TestStringLong()
//TODO: fails as FsPickler uses 2 bytes for length encoding instead of 4 as Wire does
//our payload gets bigger
- [TestMethod]
+ [Fact]
public void TestStringArray()
{
var arr = new string[1000];
@@ -124,7 +124,7 @@ public void TestStringArray()
}
- [TestMethod]
+ [Fact]
public void TestByteArray()
{
var arr = new byte[1000];
@@ -136,7 +136,7 @@ public void TestByteArray()
Test(arr);
}
- [TestMethod]
+ [Fact]
public void TestType()
{
Test(typeof(int));
@@ -145,7 +145,7 @@ public void TestType()
///fails big time, we are writing the entire qualified type name for each entry, fs pickler does not.
- [TestMethod]
+ [Fact]
public void TestTypeArray()
{
var arr = new Type[100];
@@ -157,13 +157,13 @@ public void TestTypeArray()
Test(arr);
}
- [TestMethod]
+ [Fact()]
public void TestGuid()
{
Test(Guid.NewGuid());
}
- [TestMethod]
+ [Fact]
public void TestBoolArray()
{
var arr = new bool[1000];
@@ -176,7 +176,7 @@ public void TestBoolArray()
}
- [TestMethod]
+ [Fact]
public void TestTuple()
{
Test(Tuple.Create(123,456));
@@ -189,7 +189,7 @@ public class FakeTupleIntInt
public int Item2 { get; set; }
}
- [TestMethod]
+ [Fact]
public void TestTupleLikeArray()
{
var arr = new FakeTupleIntInt[100];
@@ -205,7 +205,7 @@ public void TestTupleLikeArray()
Test(arr);
}
- [TestMethod, Ignore] //this is slow because we can not codegen setters for readonly fields yet (expressions, we need IL compiler first)
+ [Fact(Skip = "Slow test (?)")] //this is slow because we can not codegen setters for readonly fields yet (expressions, we need IL compiler first)
public void TestTupleArray()
{
var arr = new Tuple<int,int>[100];
@@ -217,7 +217,7 @@ public void TestTupleArray()
Test(arr);
}
- [TestMethod]
+ [Fact]
public void TestList()
{
var list = new List<int>()
@@ -231,13 +231,13 @@ public void TestList()
Test(list);
}
- [TestMethod]
+ [Fact]
public void TestInt()
{
Test(123456);
}
- [TestMethod]
+ [Fact]
public void TestPocoSmall()
{
Test(new Poco()
@@ -247,7 +247,7 @@ public void TestPocoSmall()
});
}
- [TestMethod]
+ [Fact]
//fails as our payload is bigger, probably due to qualified typename, we are faster though
public void TestCyclic()
{
@@ -259,7 +259,7 @@ public void TestCyclic()
Test(a);
}
- [TestMethod]
+ [Fact]
public void TestIntDictionary()
{
var dict = new Dictionary<int,int>()
@@ -271,7 +271,7 @@ public void TestIntDictionary()
Test(dict);
}
- [TestMethod]
+ [Fact]
public void TestFSharpList()
{
var list =
@@ -334,8 +334,8 @@ private static void Test(object value)
Console.WriteLine($"Wire is {picklerSize / (double)wireSize:n2} times smaller than FsPickler");
//assert that we are in a 10% margin of FsPickler
- Assert.IsTrue(wireTs <= picklerTs * 1.1, "Wire was slower than FsPickler");
- Assert.IsTrue(wireSize <= picklerSize * 1.1, "Wire payload was larger than FsPickler");
+ Assert.True(wireTs <= picklerTs * 1.1, "Wire was slower than FsPickler");
+ Assert.True(wireSize <= picklerSize * 1.1, "Wire payload was larger than FsPickler");
}
private static void WireSerialize(object value, Serializer wireSerializer, MemoryStream wireStream)
@@ -58,18 +58,30 @@
<Reference Include="System" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml" />
+ <Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
+ <HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="xunit.assert, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
+ <HintPath>..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
+ <HintPath>..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
+ <HintPath>..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
</ItemGroup>
<Choose>
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
</ItemGroup>
</When>
- <Otherwise>
- <ItemGroup>
- <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />
- </ItemGroup>
- </Otherwise>
+ <Otherwise />
</Choose>
<ItemGroup>
<Compile Include="SpeedAndSizeTests.cs" />
@@ -5,4 +5,10 @@
<package id="FsPickler.CSharp" version="3.1.0" targetFramework="net45" />
<package id="FsPickler.Json" version="3.1.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
+ <package id="xunit" version="2.1.0" targetFramework="net45" />
+ <package id="xunit.abstractions" version="2.0.0" targetFramework="net45" />
+ <package id="xunit.assert" version="2.1.0" targetFramework="net45" />
+ <package id="xunit.core" version="2.1.0" targetFramework="net45" />
+ <package id="xunit.extensibility.core" version="2.1.0" targetFramework="net45" />
+ <package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net45" />
</packages>

0 comments on commit 1de9520

Please sign in to comment.