public async stt::Task GetPartitionResourceNamesAsync() { moq::Mock <MetadataService.MetadataServiceClient> mockGrpcClient = new moq::Mock <MetadataService.MetadataServiceClient>(moq::MockBehavior.Strict); GetPartitionRequest request = new GetPartitionRequest { PartitionName = PartitionName.FromProjectLocationLakeZoneEntityPartition("[PROJECT]", "[LOCATION]", "[LAKE]", "[ZONE]", "[ENTITY]", "[PARTITION]"), }; Partition expectedResponse = new Partition { PartitionName = PartitionName.FromProjectLocationLakeZoneEntityPartition("[PROJECT]", "[LOCATION]", "[LAKE]", "[ZONE]", "[ENTITY]", "[PARTITION]"), Values = { "valueseec79cf0", }, Location = "locatione09d18d5", Etag = "etage8ad7218", }; mockGrpcClient.Setup(x => x.GetPartitionAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Partition>(stt::Task.FromResult(expectedResponse), null, null, null, null)); MetadataServiceClient client = new MetadataServiceClientImpl(mockGrpcClient.Object, null); Partition responseCallSettings = await client.GetPartitionAsync(request.PartitionName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Partition responseCancellationToken = await client.GetPartitionAsync(request.PartitionName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetEntityRequestObject() { moq::Mock <MetadataService.MetadataServiceClient> mockGrpcClient = new moq::Mock <MetadataService.MetadataServiceClient>(moq::MockBehavior.Strict); GetEntityRequest request = new GetEntityRequest { EntityName = EntityName.FromProjectLocationLakeZoneEntity("[PROJECT]", "[LOCATION]", "[LAKE]", "[ZONE]", "[ENTITY]"), View = GetEntityRequest.Types.EntityView.Basic, }; Entity expectedResponse = new Entity { EntityName = EntityName.FromProjectLocationLakeZoneEntity("[PROJECT]", "[LOCATION]", "[LAKE]", "[ZONE]", "[ENTITY]"), DisplayName = "display_name137f65c2", Description = "description2cf9da67", CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Id = "id74b70bb8", Etag = "etage8ad7218", Type = Entity.Types.Type.Unspecified, Asset = "assetd4344ec0", DataPath = "data_path6b0d38a8", DataPathPattern = "data_path_pattern534aa82f", CatalogEntry = "catalog_entry0c83a523", System = StorageSystem.CloudStorage, Format = new StorageFormat(), Compatibility = new Entity.Types.CompatibilityStatus(), Schema = new Schema(), }; mockGrpcClient.Setup(x => x.GetEntity(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); MetadataServiceClient client = new MetadataServiceClientImpl(mockGrpcClient.Object, null); Entity response = client.GetEntity(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetPartitionResourceNames() { moq::Mock <MetadataService.MetadataServiceClient> mockGrpcClient = new moq::Mock <MetadataService.MetadataServiceClient>(moq::MockBehavior.Strict); GetPartitionRequest request = new GetPartitionRequest { PartitionName = PartitionName.FromProjectLocationLakeZoneEntityPartition("[PROJECT]", "[LOCATION]", "[LAKE]", "[ZONE]", "[ENTITY]", "[PARTITION]"), }; Partition expectedResponse = new Partition { PartitionName = PartitionName.FromProjectLocationLakeZoneEntityPartition("[PROJECT]", "[LOCATION]", "[LAKE]", "[ZONE]", "[ENTITY]", "[PARTITION]"), Values = { "valueseec79cf0", }, Location = "locatione09d18d5", Etag = "etage8ad7218", }; mockGrpcClient.Setup(x => x.GetPartition(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); MetadataServiceClient client = new MetadataServiceClientImpl(mockGrpcClient.Object, null); Partition response = client.GetPartition(request.PartitionName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }