Index: third_party/grpc/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs |
diff --git a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs b/third_party/grpc/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs |
similarity index 52% |
copy from third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs |
copy to third_party/grpc/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs |
index e547d834986de8d80703504469e9c39b3d8ae93d..fac93fcc5cc09f1d56808722b399409578cf7cef 100644 |
--- a/third_party/protobuf/csharp/src/Google.Protobuf/Reflection/PackageDescriptor.cs |
+++ b/third_party/grpc/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs |
@@ -1,7 +1,7 @@ |
#region Copyright notice and license |
-// Protocol Buffers - Google's data interchange format |
-// Copyright 2008 Google Inc. All rights reserved. |
-// https://developers.google.com/protocol-buffers/ |
+ |
+// Copyright 2015-2016, Google Inc. |
+// All rights reserved. |
// |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
@@ -28,41 +28,63 @@ |
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
+ |
#endregion |
-namespace Google.Protobuf.Reflection |
+using System; |
+using System.Threading; |
+using Grpc.Core; |
+using NUnit.Framework; |
+ |
+namespace Grpc.Core.Tests |
{ |
- /// <summary> |
- /// Represents a package in the symbol table. We use PackageDescriptors |
- /// just as placeholders so that someone cannot define, say, a message type |
- /// that has the same name as an existing package. |
- /// </summary> |
- internal sealed class PackageDescriptor : IDescriptor |
+ public class GrpcEnvironmentTest |
{ |
- private readonly string name; |
- private readonly string fullName; |
- private readonly FileDescriptor file; |
+ [Test] |
+ public void InitializeAndShutdownGrpcEnvironment() |
+ { |
+ var env = GrpcEnvironment.AddRef(); |
+ Assert.IsNotNull(env.CompletionQueue); |
+ GrpcEnvironment.Release(); |
+ } |
- internal PackageDescriptor(string name, string fullName, FileDescriptor file) |
+ [Test] |
+ public void SubsequentInvocations() |
{ |
- this.file = file; |
- this.fullName = fullName; |
- this.name = name; |
+ var env1 = GrpcEnvironment.AddRef(); |
+ var env2 = GrpcEnvironment.AddRef(); |
+ Assert.AreSame(env1, env2); |
+ GrpcEnvironment.Release(); |
+ GrpcEnvironment.Release(); |
} |
- public string Name |
+ [Test] |
+ public void InitializeAfterShutdown() |
{ |
- get { return name; } |
+ Assert.AreEqual(0, GrpcEnvironment.GetRefCount()); |
+ |
+ var env1 = GrpcEnvironment.AddRef(); |
+ GrpcEnvironment.Release(); |
+ |
+ var env2 = GrpcEnvironment.AddRef(); |
+ GrpcEnvironment.Release(); |
+ |
+ Assert.AreNotSame(env1, env2); |
} |
- public string FullName |
+ [Test] |
+ public void ReleaseWithoutAddRef() |
{ |
- get { return fullName; } |
+ Assert.AreEqual(0, GrpcEnvironment.GetRefCount()); |
+ Assert.Throws(typeof(InvalidOperationException), () => GrpcEnvironment.Release()); |
} |
- public FileDescriptor File |
+ [Test] |
+ public void GetCoreVersionString() |
{ |
- get { return file; } |
+ var coreVersion = GrpcEnvironment.GetCoreVersionString(); |
+ var parts = coreVersion.Split('.'); |
+ Assert.AreEqual(3, parts.Length); |
} |
} |
-} |
+} |