Example #1
0
        public void TestInsert()
        {
            // [START insert]
            Entity task = new Entity()
            {
                Key = _keyFactory.CreateIncompleteKey()
            };

            task.Key = _db.Insert(task);
            // [END insert]
            Assert.Equal(task, _db.Lookup(task.Key));
            // Make sure a second insert throws an exception.
            Grpc.Core.RpcException e = Assert.Throws <Grpc.Core.RpcException>(() =>
                                                                              _db.Insert(task));
        }
Example #2
0
 /// <summary>
 /// Returns true if an AggregateException contains a Grpc.Core.RpcException
 /// with the given error code.
 /// </summary>
 /// <param name="e">The exception to examine.</param>
 /// <param name="errorCode">The error code to look for.</param>
 /// <returns></returns>
 static bool ContainsGrpcError(AggregateException e,
                               Grpc.Core.StatusCode errorCode)
 {
     foreach (var innerException in e.InnerExceptions)
     {
         Grpc.Core.RpcException grpcException = innerException
                                                as Grpc.Core.RpcException;
         if (grpcException != null &&
             grpcException.Status.StatusCode == errorCode)
         {
             return(true);
         }
     }
     return(false);
 }