Exemple #1
0
        public async stt::Task GetCompanyAsync()
        {
            moq::Mock <CompanyService.CompanyServiceClient> mockGrpcClient = new moq::Mock <CompanyService.CompanyServiceClient>(moq::MockBehavior.Strict);
            GetCompanyRequest request = new GetCompanyRequest
            {
                CompanyName = CompanyName.FromProjectTenantCompany("[PROJECT]", "[TENANT]", "[COMPANY]"),
            };
            Company expectedResponse = new Company
            {
                CompanyName         = CompanyName.FromProjectTenantCompany("[PROJECT]", "[TENANT]", "[COMPANY]"),
                DisplayName         = "display_name137f65c2",
                ExternalId          = "external_id9442680e",
                Size                = CompanySize.Mini,
                HeadquartersAddress = "headquarters_address64cd7eb7",
                HiringAgency        = true,
                EeoText             = "eeo_text70a1a576",
                WebsiteUri          = "website_urid0c5dfce",
                CareerSiteUri       = "career_site_uri62d45b74",
                ImageUri            = "image_urieba3b1bc",
                KeywordSearchableJobCustomAttributes =
                {
                    "keyword_searchable_job_custom_attributese72ec77c",
                },
                DerivedInfo = new Company.Types.DerivedInfo(),
                Suspended   = true,
            };

            mockGrpcClient.Setup(x => x.GetCompanyAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Company>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            CompanyServiceClient client  = new CompanyServiceClientImpl(mockGrpcClient.Object, null);
            Company responseCallSettings = await client.GetCompanyAsync(request.Name, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Company responseCancellationToken = await client.GetCompanyAsync(request.Name, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }