aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/ProtocolBuffersLite.Test/TestLiteByApi.cs
diff options
context:
space:
mode:
authorJon Skeet <jonskeet@google.com>2015-04-30 11:05:36 +0100
committerJon Skeet <jonskeet@google.com>2015-04-30 11:29:35 +0100
commitc56475088d2d36d29a2640f35b9a8621796c051c (patch)
treeeee4106598d0faf92b566f7e03930f25df38a56c /csharp/src/ProtocolBuffersLite.Test/TestLiteByApi.cs
parentce97e686826147e2a071fd2321555f7d40ec5d93 (diff)
downloadprotobuf-c56475088d2d36d29a2640f35b9a8621796c051c.tar.gz
protobuf-c56475088d2d36d29a2640f35b9a8621796c051c.tar.bz2
protobuf-c56475088d2d36d29a2640f35b9a8621796c051c.zip
Change to using xUnit for all unit tests, and fetch that via NuGet.
This includes fetching the VS unit test runner package, so that tests can be run from Visual Studio's Test Explorer.
Diffstat (limited to 'csharp/src/ProtocolBuffersLite.Test/TestLiteByApi.cs')
-rw-r--r--csharp/src/ProtocolBuffersLite.Test/TestLiteByApi.cs51
1 files changed, 25 insertions, 26 deletions
diff --git a/csharp/src/ProtocolBuffersLite.Test/TestLiteByApi.cs b/csharp/src/ProtocolBuffersLite.Test/TestLiteByApi.cs
index e44a72a8..e4f9acff 100644
--- a/csharp/src/ProtocolBuffersLite.Test/TestLiteByApi.cs
+++ b/csharp/src/ProtocolBuffersLite.Test/TestLiteByApi.cs
@@ -35,67 +35,66 @@
#endregion
using Google.ProtocolBuffers.TestProtos;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Xunit;
namespace Google.ProtocolBuffers
{
- [TestClass]
public class TestLiteByApi
{
- [TestMethod]
+ [Fact]
public void TestAllTypesEquality()
{
TestAllTypesLite msg = TestAllTypesLite.DefaultInstance;
TestAllTypesLite copy = msg.ToBuilder().Build();
- Assert.AreEqual(msg.GetHashCode(), copy.GetHashCode());
- Assert.IsTrue(msg.Equals(copy));
+ Assert.Equal(msg.GetHashCode(), copy.GetHashCode());
+ Assert.True(msg.Equals(copy));
msg = msg.ToBuilder().SetOptionalString("Hi").Build();
- Assert.AreNotEqual(msg.GetHashCode(), copy.GetHashCode());
- Assert.IsFalse(msg.Equals(copy));
+ Assert.NotEqual(msg.GetHashCode(), copy.GetHashCode());
+ Assert.False(msg.Equals(copy));
copy = copy.ToBuilder().SetOptionalString("Hi").Build();
- Assert.AreEqual(msg.GetHashCode(), copy.GetHashCode());
- Assert.IsTrue(msg.Equals(copy));
+ Assert.Equal(msg.GetHashCode(), copy.GetHashCode());
+ Assert.True(msg.Equals(copy));
}
- [TestMethod]
+ [Fact]
public void TestEqualityOnExtensions()
{
TestAllExtensionsLite msg = TestAllExtensionsLite.DefaultInstance;
TestAllExtensionsLite copy = msg.ToBuilder().Build();
- Assert.AreEqual(msg.GetHashCode(), copy.GetHashCode());
- Assert.IsTrue(msg.Equals(copy));
+ Assert.Equal(msg.GetHashCode(), copy.GetHashCode());
+ Assert.True(msg.Equals(copy));
msg = msg.ToBuilder().SetExtension(UnittestLite.OptionalStringExtensionLite, "Hi").Build();
- Assert.AreNotEqual(msg.GetHashCode(), copy.GetHashCode());
- Assert.IsFalse(msg.Equals(copy));
+ Assert.NotEqual(msg.GetHashCode(), copy.GetHashCode());
+ Assert.False(msg.Equals(copy));
copy = copy.ToBuilder().SetExtension(UnittestLite.OptionalStringExtensionLite, "Hi").Build();
- Assert.AreEqual(msg.GetHashCode(), copy.GetHashCode());
- Assert.IsTrue(msg.Equals(copy));
+ Assert.Equal(msg.GetHashCode(), copy.GetHashCode());
+ Assert.True(msg.Equals(copy));
}
- [TestMethod]
+ [Fact]
public void TestAllTypesToString()
{
TestAllTypesLite msg = TestAllTypesLite.DefaultInstance;
TestAllTypesLite copy = msg.ToBuilder().Build();
- Assert.AreEqual(msg.ToString(), copy.ToString());
- Assert.AreEqual(0, msg.ToString().Length);
+ Assert.Equal(msg.ToString(), copy.ToString());
+ Assert.Equal(0, msg.ToString().Length);
msg = msg.ToBuilder().SetOptionalInt32(-1).Build();
- Assert.AreEqual("optional_int32: -1", msg.ToString().TrimEnd());
+ Assert.Equal("optional_int32: -1", msg.ToString().TrimEnd());
msg = msg.ToBuilder().SetOptionalString("abc123").Build();
- Assert.AreEqual("optional_int32: -1\noptional_string: \"abc123\"",
+ Assert.Equal("optional_int32: -1\noptional_string: \"abc123\"",
msg.ToString().Replace("\r", "").TrimEnd());
}
- [TestMethod]
+ [Fact]
public void TestAllTypesDefaultedRoundTrip()
{
TestAllTypesLite msg = TestAllTypesLite.DefaultInstance;
- Assert.IsTrue(msg.IsInitialized);
+ Assert.True(msg.IsInitialized);
TestAllTypesLite copy = TestAllTypesLite.CreateBuilder().MergeFrom(msg.ToByteArray()).Build();
- TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
+ Assert.Equal(msg.ToByteArray(), copy.ToByteArray());
}
- [TestMethod]
+ [Fact]
public void TestAllTypesModifiedRoundTrip()
{
TestAllTypesLite msg = TestAllTypesLite.DefaultInstance;
@@ -115,7 +114,7 @@ namespace Google.ProtocolBuffers
.AddRepeatedGroup(TestAllTypesLite.Types.RepeatedGroup.CreateBuilder().SetA('A').Build())
;
TestAllTypesLite copy = TestAllTypesLite.CreateBuilder().MergeFrom(msg.ToByteArray()).Build();
- TestUtil.AssertBytesEqual(msg.ToByteArray(), copy.ToByteArray());
+ Assert.Equal(msg.ToByteArray(), copy.ToByteArray());
}
}
} \ No newline at end of file