public void NoHeaderOnGetSessionIfEmptySessionName()
        {
            var invoker = new FakeCallInvoker();
            var client = new SpannerClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.GetSession(new GetSessionRequest());
            Assert.Null(invoker.Metadata.FirstOrDefault(e => e.Key == ResourcePrefixHeader));
        }
Ejemplo n.º 2
0
        public void NoHeaderOnGetBackupIfEmptyBackupName()
        {
            var invoker = new FakeCallInvoker();
            var client = new DatabaseAdminClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.GetBackup(new GetBackupRequest());
            Assert.Null(invoker.Metadata.FirstOrDefault(e => e.Key == ResourcePrefixHeader));
        }
Ejemplo n.º 3
0
        public void NoHeaderOnCreateDatabaseIfEmptyInstanceName()
        {
            var invoker = new FakeCallInvoker();
            var client = new DatabaseAdminClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.CreateDatabase(new CreateDatabaseRequest());
            Assert.Null(invoker.Metadata.FirstOrDefault(e => e.Key == ResourcePrefixHeader));
        }
        public void NoHeaderOnGetInstanceConfigIfEmptyInstanceConfigName()
        {
            var invoker = new FakeCallInvoker();
            var client = new InstanceAdminClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.GetInstanceConfig(new GetInstanceConfigRequest());
            Assert.Null(invoker.Metadata.FirstOrDefault(e => e.Key == ResourcePrefixHeader));
        }
Ejemplo n.º 5
0
        public void NoHeaderOnGetBackupIfInvalidBackupName()
        {
            var invoker = new FakeCallInvoker();
            var client = new DatabaseAdminClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.GetBackup(new GetBackupRequest {
                Name = "projects/proj/instances/inst/backups"
            });
            Assert.Null(invoker.Metadata.FirstOrDefault(e => e.Key == ResourcePrefixHeader));
        }
        public void NoHeaderOnGetSessionIfInvalidSessionName()
        {
            var invoker = new FakeCallInvoker();
            var client = new SpannerClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.GetSession(new GetSessionRequest {
                Name = "projects/proj/instances/inst/databases/sessions"
            });
            Assert.Null(invoker.Metadata.FirstOrDefault(e => e.Key == ResourcePrefixHeader));
        }
        public void NoHeaderOnCreateInstanceIfInvalidProjectName()
        {
            var invoker = new FakeCallInvoker();
            var client = new InstanceAdminClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.CreateInstance(new CreateInstanceRequest {
                Parent = "projects"
            });
            Assert.Null(invoker.Metadata.FirstOrDefault(e => e.Key == ResourcePrefixHeader));
        }
Ejemplo n.º 8
0
        public void SetsHeaderOnListBackupOperations()
        {
            var invoker = new FakeCallInvoker();
            var client = new DatabaseAdminClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.ListBackupOperations(new ListBackupOperationsRequest {
                Parent = SampleInstanceName
            }).AsRawResponses().First();
            Metadata.Entry entry = Assert.Single(invoker.Metadata, e => e.Key == ResourcePrefixHeader);
            Assert.Equal(SampleInstanceName, entry.Value);
        }
Ejemplo n.º 9
0
        public void SetsHeaderOnRestoreDatabase()
        {
            var invoker = new FakeCallInvoker();
            var client = new DatabaseAdminClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.RestoreDatabase(new RestoreDatabaseRequest {
                Parent = SampleInstanceName
            });
            Metadata.Entry entry = Assert.Single(invoker.Metadata, e => e.Key == ResourcePrefixHeader);
            Assert.Equal(SampleInstanceName, entry.Value);
        }
Ejemplo n.º 10
0
        public void SetsHeaderOnGetDatabaseDdl()
        {
            var invoker = new FakeCallInvoker();
            var client = new DatabaseAdminClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.GetDatabaseDdl(new GetDatabaseDdlRequest {
                Database = SampleDatabaseName
            });
            Metadata.Entry entry = Assert.Single(invoker.Metadata, e => e.Key == ResourcePrefixHeader);
            Assert.Equal(SampleDatabaseName, entry.Value);
        }
        public void SetsHeaderOnBatchCreateSessions()
        {
            var invoker = new FakeCallInvoker();
            var client = new SpannerClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.BatchCreateSessions(new BatchCreateSessionsRequest {
                Database = SampleDatabaseName
            });
            Metadata.Entry entry = Assert.Single(invoker.Metadata, e => e.Key == ResourcePrefixHeader);
            Assert.Equal(SampleDatabaseName, entry.Value);
        }
        public void SetsHeaderOnPartitionQuery()
        {
            var invoker = new FakeCallInvoker();
            var client = new SpannerClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.PartitionQuery(new PartitionQueryRequest {
                Session = SampleSessionName
            });
            Metadata.Entry entry = Assert.Single(invoker.Metadata, e => e.Key == ResourcePrefixHeader);
            Assert.Equal(SampleDatabaseName, entry.Value);
        }
        public void SetsHeaderOnGetInstanceConfig()
        {
            var invoker = new FakeCallInvoker();
            var client = new InstanceAdminClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.GetInstanceConfig(new GetInstanceConfigRequest {
                Name = SampleInstanceConfigName
            });
            Metadata.Entry entry = Assert.Single(invoker.Metadata, e => e.Key == ResourcePrefixHeader);
            Assert.Equal(SampleProjectName, entry.Value);
        }
Ejemplo n.º 14
0
        public void SetsHeaderOnUpdateBackup()
        {
            var invoker = new FakeCallInvoker();
            var client = new DatabaseAdminClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.UpdateBackup(new UpdateBackupRequest
            {
                Backup = new Backup {
                    Name = SampleBackupName
                }
            });
            Metadata.Entry entry = Assert.Single(invoker.Metadata, e => e.Key == ResourcePrefixHeader);
            Assert.Equal(SampleInstanceName, entry.Value);
        }
Ejemplo n.º 15
0
            public void CallInvoker_SetBefore()
            {
                var manual            = new FakeCallInvoker();
                var injected          = new FakeCallInvoker();
                var serviceCollection = new ServiceCollection();

                serviceCollection.AddSingleton <CallInvoker>(injected);
                serviceCollection.AddGrpcNetClientAdapter();
                var builder = new FakeBuilder {
                    CallInvoker = manual
                };

                builder.Configure(serviceCollection);
                Assert.Same(manual, builder.CallInvoker);
                // Because the CallInvoker was set, the gRPC adapter wasn't injected
                Assert.Null(builder.GrpcAdapter);
            }
Ejemplo n.º 16
0
        public void ClientProvidesHeader()
        {
            var invoker = new FakeCallInvoker();
            var client = new LanguageServiceClientBuilder {
                CallInvoker = invoker
            }.Build();

            client.AnnotateText(Document.FromPlainText("Some text"), new Features {
                ClassifyText = true
            });
            var metadata = invoker.Metadata;
            var entry    = metadata.FirstOrDefault(pair => pair.Key == "x-goog-api-client");

            Assert.NotNull(entry);
            var keys = entry.Value.Split(' ')
                       .Select(value => value.Split('/')[0])
                       .OrderBy(key => key)
                       .ToList();

            string[] expectedKeys = { "gapic", "gax", "gccl", "gl-dotnet", "grpc" };
            Assert.Equal(expectedKeys, keys);
        }