public void CreateTenant() { moq::Mock <TenantService.TenantServiceClient> mockGrpcClient = new moq::Mock <TenantService.TenantServiceClient>(moq::MockBehavior.Strict); CreateTenantRequest request = new CreateTenantRequest { ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"), Tenant = new Tenant(), }; Tenant expectedResponse = new Tenant { TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"), ExternalId = "external_id9442680e", UsageType = Tenant.Types.DataUsageType.Unspecified, KeywordSearchableProfileCustomAttributes = { "keyword_searchable_profile_custom_attributes9dbf9d03", }, }; mockGrpcClient.Setup(x => x.CreateTenant(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); TenantServiceClient client = new TenantServiceClientImpl(mockGrpcClient.Object, null); Tenant response = client.CreateTenant(request.Parent, request.Tenant); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task CreateTenantRequestObjectAsync() { moq::Mock <TenantService.TenantServiceClient> mockGrpcClient = new moq::Mock <TenantService.TenantServiceClient>(moq::MockBehavior.Strict); CreateTenantRequest request = new CreateTenantRequest { ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"), Tenant = new Tenant(), }; Tenant expectedResponse = new Tenant { TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"), ExternalId = "external_id9442680e", UsageType = Tenant.Types.DataUsageType.Unspecified, KeywordSearchableProfileCustomAttributes = { "keyword_searchable_profile_custom_attributes9dbf9d03", }, }; mockGrpcClient.Setup(x => x.CreateTenantAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Tenant>(stt::Task.FromResult(expectedResponse), null, null, null, null)); TenantServiceClient client = new TenantServiceClientImpl(mockGrpcClient.Object, null); Tenant responseCallSettings = await client.CreateTenantAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Tenant responseCancellationToken = await client.CreateTenantAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task DeleteTenantAsync2() { Mock <TenantService.TenantServiceClient> mockGrpcClient = new Mock <TenantService.TenantServiceClient>(MockBehavior.Strict); DeleteTenantRequest request = new DeleteTenantRequest { TenantName = new TenantName("[PROJECT]", "[TENANT]"), }; Empty expectedResponse = new Empty(); mockGrpcClient.Setup(x => x.DeleteTenantAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Empty>(Task.FromResult(expectedResponse), null, null, null, null)); TenantServiceClient client = new TenantServiceClientImpl(mockGrpcClient.Object, null); await client.DeleteTenantAsync(request); mockGrpcClient.VerifyAll(); }
public void DeleteTenantResourceNames() { moq::Mock <TenantService.TenantServiceClient> mockGrpcClient = new moq::Mock <TenantService.TenantServiceClient>(moq::MockBehavior.Strict); DeleteTenantRequest request = new DeleteTenantRequest { TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteTenant(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); TenantServiceClient client = new TenantServiceClientImpl(mockGrpcClient.Object, null); client.DeleteTenant(request.TenantName); mockGrpcClient.VerifyAll(); }
public void DeleteTenant2() { Mock <TenantService.TenantServiceClient> mockGrpcClient = new Mock <TenantService.TenantServiceClient>(MockBehavior.Strict); DeleteTenantRequest request = new DeleteTenantRequest { TenantName = new TenantName("[PROJECT]", "[TENANT]"), }; Empty expectedResponse = new Empty(); mockGrpcClient.Setup(x => x.DeleteTenant(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); TenantServiceClient client = new TenantServiceClientImpl(mockGrpcClient.Object, null); client.DeleteTenant(request); mockGrpcClient.VerifyAll(); }
public async stt::Task DeleteTenantResourceNamesAsync() { moq::Mock <TenantService.TenantServiceClient> mockGrpcClient = new moq::Mock <TenantService.TenantServiceClient>(moq::MockBehavior.Strict); DeleteTenantRequest request = new DeleteTenantRequest { TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteTenantAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); TenantServiceClient client = new TenantServiceClientImpl(mockGrpcClient.Object, null); await client.DeleteTenantAsync(request.TenantName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.DeleteTenantAsync(request.TenantName, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }
public void GetTenantResourceNames() { moq::Mock <TenantService.TenantServiceClient> mockGrpcClient = new moq::Mock <TenantService.TenantServiceClient>(moq::MockBehavior.Strict); GetTenantRequest request = new GetTenantRequest { TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"), }; Tenant expectedResponse = new Tenant { TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"), ExternalId = "external_id9442680e", }; mockGrpcClient.Setup(x => x.GetTenant(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); TenantServiceClient client = new TenantServiceClientImpl(mockGrpcClient.Object, null); Tenant response = client.GetTenant(request.TenantName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task UpdateTenantAsync2() { Mock <TenantService.TenantServiceClient> mockGrpcClient = new Mock <TenantService.TenantServiceClient>(MockBehavior.Strict); UpdateTenantRequest request = new UpdateTenantRequest { Tenant = new Tenant(), }; Tenant expectedResponse = new Tenant { TenantName = new TenantName("[PROJECT]", "[TENANT]"), ExternalId = "externalId-1153075697", }; mockGrpcClient.Setup(x => x.UpdateTenantAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Tenant>(Task.FromResult(expectedResponse), null, null, null, null)); TenantServiceClient client = new TenantServiceClientImpl(mockGrpcClient.Object, null); Tenant response = await client.UpdateTenantAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void UpdateTenant2() { Mock <TenantService.TenantServiceClient> mockGrpcClient = new Mock <TenantService.TenantServiceClient>(MockBehavior.Strict); UpdateTenantRequest request = new UpdateTenantRequest { Tenant = new Tenant(), }; Tenant expectedResponse = new Tenant { TenantName = new TenantName("[PROJECT]", "[TENANT]"), ExternalId = "externalId-1153075697", }; mockGrpcClient.Setup(x => x.UpdateTenant(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); TenantServiceClient client = new TenantServiceClientImpl(mockGrpcClient.Object, null); Tenant response = client.UpdateTenant(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetTenantResourceNamesAsync() { moq::Mock <TenantService.TenantServiceClient> mockGrpcClient = new moq::Mock <TenantService.TenantServiceClient>(moq::MockBehavior.Strict); GetTenantRequest request = new GetTenantRequest { TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"), }; Tenant expectedResponse = new Tenant { TenantName = TenantName.FromProjectTenant("[PROJECT]", "[TENANT]"), ExternalId = "external_id9442680e", }; mockGrpcClient.Setup(x => x.GetTenantAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Tenant>(stt::Task.FromResult(expectedResponse), null, null, null, null)); TenantServiceClient client = new TenantServiceClientImpl(mockGrpcClient.Object, null); Tenant responseCallSettings = await client.GetTenantAsync(request.TenantName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Tenant responseCancellationToken = await client.GetTenantAsync(request.TenantName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }