diff options
author | Jon Skeet <jonskeet@google.com> | 2015-04-30 11:05:36 +0100 |
---|---|---|
committer | Jon Skeet <jonskeet@google.com> | 2015-04-30 11:29:35 +0100 |
commit | c56475088d2d36d29a2640f35b9a8621796c051c (patch) | |
tree | eee4106598d0faf92b566f7e03930f25df38a56c /csharp/src/ProtocolBuffersLite.Test/InteropLiteTest.cs | |
parent | ce97e686826147e2a071fd2321555f7d40ec5d93 (diff) | |
download | protobuf-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/InteropLiteTest.cs')
-rw-r--r-- | csharp/src/ProtocolBuffersLite.Test/InteropLiteTest.cs | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/csharp/src/ProtocolBuffersLite.Test/InteropLiteTest.cs b/csharp/src/ProtocolBuffersLite.Test/InteropLiteTest.cs index 0640a445..7feb0448 100644 --- a/csharp/src/ProtocolBuffersLite.Test/InteropLiteTest.cs +++ b/csharp/src/ProtocolBuffersLite.Test/InteropLiteTest.cs @@ -35,31 +35,28 @@ #endregion
using System;
-using System.Collections.Generic;
-using Google.ProtocolBuffers;
using Google.ProtocolBuffers.TestProtos;
-using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Xunit;
namespace Google.ProtocolBuffers
{
- [TestClass]
public class InteropLiteTest
{
- [TestMethod]
+ [Fact]
public void TestConvertFromFullMinimal()
{
TestInteropPerson person = TestInteropPerson.CreateBuilder()
.SetId(123)
.SetName("abc")
.Build();
- Assert.IsTrue(person.IsInitialized);
+ Assert.True(person.IsInitialized);
TestInteropPersonLite copy = TestInteropPersonLite.ParseFrom(person.ToByteArray());
- TestUtil.AssertBytesEqual(person.ToByteArray(), copy.ToByteArray());
+ Assert.Equal(person.ToByteArray(), copy.ToByteArray());
}
- [TestMethod]
+ [Fact]
public void TestConvertFromFullComplete()
{
TestInteropPerson person = TestInteropPerson.CreateBuilder()
@@ -75,7 +72,7 @@ namespace Google.ProtocolBuffers .SetExtension(UnittestExtrasFull.EmployeeId,
TestInteropEmployeeId.CreateBuilder().SetNumber("123").Build())
.Build();
- Assert.IsTrue(person.IsInitialized);
+ Assert.True(person.IsInitialized);
ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnittestExtrasLite.RegisterAllExtensions(registry);
@@ -84,24 +81,24 @@ namespace Google.ProtocolBuffers TestInteropPersonLite copy = TestInteropPersonLite.ParseFrom(fullBytes, registry);
byte[] liteBytes = copy.ToByteArray();
- TestUtil.AssertBytesEqual(fullBytes, liteBytes);
+ Assert.Equal(fullBytes, liteBytes);
}
- [TestMethod]
+ [Fact]
public void TestConvertFromLiteMinimal()
{
TestInteropPersonLite person = TestInteropPersonLite.CreateBuilder()
.SetId(123)
.SetName("abc")
.Build();
- Assert.IsTrue(person.IsInitialized);
+ Assert.True(person.IsInitialized);
TestInteropPerson copy = TestInteropPerson.ParseFrom(person.ToByteArray());
- TestUtil.AssertBytesEqual(person.ToByteArray(), copy.ToByteArray());
+ Assert.Equal(person.ToByteArray(), copy.ToByteArray());
}
- [TestMethod]
+ [Fact]
public void TestConvertFromLiteComplete()
{
TestInteropPersonLite person = TestInteropPersonLite.CreateBuilder()
@@ -117,14 +114,14 @@ namespace Google.ProtocolBuffers .SetExtension(UnittestExtrasLite.EmployeeIdLite,
TestInteropEmployeeIdLite.CreateBuilder().SetNumber("123").Build())
.Build();
- Assert.IsTrue(person.IsInitialized);
+ Assert.True(person.IsInitialized);
ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnittestExtrasFull.RegisterAllExtensions(registry);
TestInteropPerson copy = TestInteropPerson.ParseFrom(person.ToByteArray(), registry);
- TestUtil.AssertBytesEqual(person.ToByteArray(), copy.ToByteArray());
+ Assert.Equal(person.ToByteArray(), copy.ToByteArray());
}
public ByteString AllBytes
@@ -138,7 +135,7 @@ namespace Google.ProtocolBuffers }
}
- [TestMethod]
+ [Fact]
public void TestCompareStringValues()
{
TestInteropPersonLite person = TestInteropPersonLite.CreateBuilder()
@@ -156,14 +153,14 @@ namespace Google.ProtocolBuffers .SetExtension(UnittestExtrasLite.EmployeeIdLite,
TestInteropEmployeeIdLite.CreateBuilder().SetNumber("123").Build())
.Build();
- Assert.IsTrue(person.IsInitialized);
+ Assert.True(person.IsInitialized);
ExtensionRegistry registry = ExtensionRegistry.CreateInstance();
UnittestExtrasFull.RegisterAllExtensions(registry);
TestInteropPerson copy = TestInteropPerson.ParseFrom(person.ToByteArray(), registry);
- TestUtil.AssertBytesEqual(person.ToByteArray(), copy.ToByteArray());
+ Assert.Equal(person.ToByteArray(), copy.ToByteArray());
TestInteropPerson.Builder copyBuilder = TestInteropPerson.CreateBuilder();
TextFormat.Merge(
@@ -171,7 +168,7 @@ namespace Google.ProtocolBuffers "[protobuf_unittest_extra.employee_id]"), registry, copyBuilder);
copy = copyBuilder.Build();
- TestUtil.AssertBytesEqual(person.ToByteArray(), copy.ToByteArray());
+ Assert.Equal(person.ToByteArray(), copy.ToByteArray());
string liteText = person.ToString().TrimEnd().Replace("\r", "");
string fullText = copy.ToString().TrimEnd().Replace("\r", "");
@@ -179,10 +176,10 @@ namespace Google.ProtocolBuffers liteText = liteText.Replace("[protobuf_unittest_extra.employee_id_lite]",
"[protobuf_unittest_extra.employee_id]");
//lite version does not indent
- while (fullText.IndexOf("\n ") >= 0)
+ while (fullText.IndexOf("\n ", StringComparison.Ordinal) >= 0)
fullText = fullText.Replace("\n ", "\n");
- Assert.AreEqual(fullText, liteText);
+ Assert.Equal(fullText, liteText);
}
}
}
\ No newline at end of file |