public async Task CreateCompanyAsync() { Mock <CompanyService.CompanyServiceClient> mockGrpcClient = new Mock <CompanyService.CompanyServiceClient>(MockBehavior.Strict); CreateCompanyRequest expectedRequest = new CreateCompanyRequest { ParentAsTenantOrProjectNameOneof = TenantOrProjectNameOneof.From(new TenantName("[PROJECT]", "[TENANT]")), Company = new Company(), }; Company expectedResponse = new Company { CompanyNameOneof = CompanyNameOneof.From(new CompanyOldName("[PROJECT]", "[COMPANY]")), DisplayName = "displayName1615086568", ExternalId = "externalId-1153075697", HeadquartersAddress = "headquartersAddress-1879520036", HiringAgency = false, EeoText = "eeoText-1652097123", WebsiteUri = "websiteUri-2118185016", CareerSiteUri = "careerSiteUri1223331861", ImageUri = "imageUri-877823864", Suspended = false, }; mockGrpcClient.Setup(x => x.CreateCompanyAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Company>(Task.FromResult(expectedResponse), null, null, null, null)); CompanyServiceClient client = new CompanyServiceClientImpl(mockGrpcClient.Object, null); TenantOrProjectNameOneof parent = TenantOrProjectNameOneof.From(new TenantName("[PROJECT]", "[TENANT]")); Company company = new Company(); Company response = await client.CreateCompanyAsync(parent, company); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void UpdateCompany2() { Mock <CompanyService.CompanyServiceClient> mockGrpcClient = new Mock <CompanyService.CompanyServiceClient>(MockBehavior.Strict); UpdateCompanyRequest request = new UpdateCompanyRequest { Company = new Company(), }; Company expectedResponse = new Company { CompanyNameOneof = CompanyNameOneof.From(new CompanyOldName("[PROJECT]", "[COMPANY]")), DisplayName = "displayName1615086568", ExternalId = "externalId-1153075697", HeadquartersAddress = "headquartersAddress-1879520036", HiringAgency = false, EeoText = "eeoText-1652097123", WebsiteUri = "websiteUri-2118185016", CareerSiteUri = "careerSiteUri1223331861", ImageUri = "imageUri-877823864", Suspended = false, }; mockGrpcClient.Setup(x => x.UpdateCompany(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); CompanyServiceClient client = new CompanyServiceClientImpl(mockGrpcClient.Object, null); Company response = client.UpdateCompany(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task CreateJobAsync() { Mock <JobService.JobServiceClient> mockGrpcClient = new Mock <JobService.JobServiceClient>(MockBehavior.Strict); CreateJobRequest expectedRequest = new CreateJobRequest { ParentAsTenantOrProjectNameOneof = TenantOrProjectNameOneof.From(new TenantName("[PROJECT]", "[TENANT]")), Job = new Job(), }; Job expectedResponse = new Job { JobNameOneof = JobNameOneof.From(new JobName("[PROJECT]", "[TENANT]", "[JOBS]")), CompanyAsCompanyNameOneof = CompanyNameOneof.From(new CompanyName("[PROJECT]", "[TENANT]", "[COMPANY]")), RequisitionId = "requisitionId980224926", Title = "title110371416", Description = "description-1724546052", Department = "department848184146", Incentives = "incentives-1262874520", LanguageCode = "languageCode-412800396", PromotionValue = 353413845, Qualifications = "qualifications1903501412", Responsibilities = "responsibilities-926952660", CompanyDisplayName = "companyDisplayName1982424170", }; mockGrpcClient.Setup(x => x.CreateJobAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Job>(Task.FromResult(expectedResponse), null, null, null, null)); JobServiceClient client = new JobServiceClientImpl(mockGrpcClient.Object, null); TenantOrProjectNameOneof parent = TenantOrProjectNameOneof.From(new TenantName("[PROJECT]", "[TENANT]")); Job job = new Job(); Job response = await client.CreateJobAsync(parent, job); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void UpdateJob2() { Mock <JobService.JobServiceClient> mockGrpcClient = new Mock <JobService.JobServiceClient>(MockBehavior.Strict); UpdateJobRequest request = new UpdateJobRequest { Job = new Job(), }; Job expectedResponse = new Job { JobNameOneof = JobNameOneof.From(new JobName("[PROJECT]", "[TENANT]", "[JOBS]")), CompanyAsCompanyNameOneof = CompanyNameOneof.From(new CompanyName("[PROJECT]", "[TENANT]", "[COMPANY]")), RequisitionId = "requisitionId980224926", Title = "title110371416", Description = "description-1724546052", Department = "department848184146", Incentives = "incentives-1262874520", LanguageCode = "languageCode-412800396", PromotionValue = 353413845, Qualifications = "qualifications1903501412", Responsibilities = "responsibilities-926952660", CompanyDisplayName = "companyDisplayName1982424170", }; mockGrpcClient.Setup(x => x.UpdateJob(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); JobServiceClient client = new JobServiceClientImpl(mockGrpcClient.Object, null); Job response = client.UpdateJob(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetCompany</summary> public void GetCompany() { // Snippet: GetCompany(CompanyNameOneof,CallSettings) // Create client CompanyServiceClient companyServiceClient = CompanyServiceClient.Create(); // Initialize request argument(s) CompanyNameOneof name = CompanyNameOneof.From(new CompanyName("[PROJECT]", "[TENANT]", "[COMPANY]")); // Make the request Company response = companyServiceClient.GetCompany(name); // End snippet }
/// <summary>Snippet for DeleteCompanyAsync</summary> public async Task DeleteCompanyAsync() { // Snippet: DeleteCompanyAsync(CompanyNameOneof,CallSettings) // Additional: DeleteCompanyAsync(CompanyNameOneof,CancellationToken) // Create client CompanyServiceClient companyServiceClient = await CompanyServiceClient.CreateAsync(); // Initialize request argument(s) CompanyNameOneof name = CompanyNameOneof.From(new CompanyName("[PROJECT]", "[TENANT]", "[COMPANY]")); // Make the request await companyServiceClient.DeleteCompanyAsync(name); // End snippet }
/// <summary>Snippet for GetCompany</summary> public void GetCompany_RequestObject() { // Snippet: GetCompany(GetCompanyRequest,CallSettings) // Create client CompanyServiceClient companyServiceClient = CompanyServiceClient.Create(); // Initialize request argument(s) GetCompanyRequest request = new GetCompanyRequest { CompanyNameOneof = CompanyNameOneof.From(new CompanyName("[PROJECT]", "[TENANT]", "[COMPANY]")), }; // Make the request Company response = companyServiceClient.GetCompany(request); // End snippet }
/// <summary>Snippet for DeleteCompany</summary> public void DeleteCompany_RequestObject() { // Snippet: DeleteCompany(DeleteCompanyRequest,CallSettings) // Create client CompanyServiceClient companyServiceClient = CompanyServiceClient.Create(); // Initialize request argument(s) DeleteCompanyRequest request = new DeleteCompanyRequest { CompanyNameOneof = CompanyNameOneof.From(new CompanyOldName("[PROJECT]", "[COMPANY]")), }; // Make the request companyServiceClient.DeleteCompany(request); // End snippet }
// [START job_search_get_company_beta] public static object GetCompany(string projectId, string tenantId, string companyId) { CompanyServiceClient companyServiceClient = CompanyServiceClient.Create(); CompanyName company = new CompanyName(projectId, tenantId, companyId); GetCompanyRequest request = new GetCompanyRequest { CompanyNameOneof = CompanyNameOneof.From(company) }; var response = companyServiceClient.GetCompany(request); Console.WriteLine($"Company name: {response.Name}"); Console.WriteLine($"Display name: {response.DisplayName}"); return(0); }
public async Task DeleteCompanyAsync2() { Mock <CompanyService.CompanyServiceClient> mockGrpcClient = new Mock <CompanyService.CompanyServiceClient>(MockBehavior.Strict); DeleteCompanyRequest request = new DeleteCompanyRequest { CompanyNameOneof = CompanyNameOneof.From(new CompanyOldName("[PROJECT]", "[COMPANY]")), }; Empty expectedResponse = new Empty(); mockGrpcClient.Setup(x => x.DeleteCompanyAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Empty>(Task.FromResult(expectedResponse), null, null, null, null)); CompanyServiceClient client = new CompanyServiceClientImpl(mockGrpcClient.Object, null); await client.DeleteCompanyAsync(request); mockGrpcClient.VerifyAll(); }
public void DeleteCompany2() { Mock <CompanyService.CompanyServiceClient> mockGrpcClient = new Mock <CompanyService.CompanyServiceClient>(MockBehavior.Strict); DeleteCompanyRequest request = new DeleteCompanyRequest { CompanyNameOneof = CompanyNameOneof.From(new CompanyOldName("[PROJECT]", "[COMPANY]")), }; Empty expectedResponse = new Empty(); mockGrpcClient.Setup(x => x.DeleteCompany(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); CompanyServiceClient client = new CompanyServiceClientImpl(mockGrpcClient.Object, null); client.DeleteCompany(request); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetCompanyAsync</summary> public async Task GetCompanyAsync_RequestObject() { // Snippet: GetCompanyAsync(GetCompanyRequest,CallSettings) // Additional: GetCompanyAsync(GetCompanyRequest,CancellationToken) // Create client CompanyServiceClient companyServiceClient = await CompanyServiceClient.CreateAsync(); // Initialize request argument(s) GetCompanyRequest request = new GetCompanyRequest { CompanyNameOneof = CompanyNameOneof.From(new CompanyName("[PROJECT]", "[TENANT]", "[COMPANY]")), }; // Make the request Company response = await companyServiceClient.GetCompanyAsync(request); // End snippet }