public async stt::Task GetFieldResourceNamesAsync() { moq::Mock <FirestoreAdmin.FirestoreAdminClient> mockGrpcClient = new moq::Mock <FirestoreAdmin.FirestoreAdminClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetFieldRequest request = new GetFieldRequest { FieldName = FieldName.FromProjectDatabaseCollectionField("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]"), }; Field expectedResponse = new Field { FieldName = FieldName.FromProjectDatabaseCollectionField("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]"), IndexConfig = new Field.Types.IndexConfig(), }; mockGrpcClient.Setup(x => x.GetFieldAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Field>(stt::Task.FromResult(expectedResponse), null, null, null, null)); FirestoreAdminClient client = new FirestoreAdminClientImpl(mockGrpcClient.Object, null); Field responseCallSettings = await client.GetFieldAsync(request.FieldName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Field responseCancellationToken = await client.GetFieldAsync(request.FieldName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void TestGetField() { var localName = "GetField.docx"; var remoteName = "TestGetField.docx"; var fullName = Path.Combine(this.dataFolder, remoteName); var fieldIndex = 0; this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir(this.fieldFolder) + localName)); var request = new GetFieldRequest(remoteName, fieldIndex, this.dataFolder, nodePath: "sections/0/paragraphs/0"); var actual = this.WordsApi.GetField(request); Assert.AreEqual(200, actual.Code); }
/// <summary>Snippet for GetField</summary> public void GetField_RequestObject() { // Snippet: GetField(GetFieldRequest,CallSettings) // Create client FirestoreAdminClient firestoreAdminClient = FirestoreAdminClient.Create(); // Initialize request argument(s) GetFieldRequest request = new GetFieldRequest { FieldName = new FieldName("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[FIELD_ID]"), }; // Make the request apis::Field response = firestoreAdminClient.GetField(request); // End snippet }
/// <summary>Snippet for GetFieldAsync</summary> public async Task GetFieldAsync_RequestObject() { // Snippet: GetFieldAsync(GetFieldRequest,CallSettings) // Additional: GetFieldAsync(GetFieldRequest,CancellationToken) // Create client FirestoreAdminClient firestoreAdminClient = await FirestoreAdminClient.CreateAsync(); // Initialize request argument(s) GetFieldRequest request = new GetFieldRequest { FieldName = new FieldName("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[FIELD_ID]"), }; // Make the request apis::Field response = await firestoreAdminClient.GetFieldAsync(request); // End snippet }
public void GetFieldResourceNames() { moq::Mock<FirestoreAdmin.FirestoreAdminClient> mockGrpcClient = new moq::Mock<FirestoreAdmin.FirestoreAdminClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock<lro::Operations.OperationsClient>().Object); GetFieldRequest request = new GetFieldRequest { FieldName = FieldName.FromProjectDatabaseCollectionField("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]"), }; Field expectedResponse = new Field { FieldName = FieldName.FromProjectDatabaseCollectionField("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]"), IndexConfig = new Field.Types.IndexConfig(), }; mockGrpcClient.Setup(x => x.GetField(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse); FirestoreAdminClient client = new FirestoreAdminClientImpl(mockGrpcClient.Object, null); Field response = client.GetField(request.FieldName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task GetFieldAsync2() { Mock <FirestoreAdmin.FirestoreAdminClient> mockGrpcClient = new Mock <FirestoreAdmin.FirestoreAdminClient>(MockBehavior.Strict); GetFieldRequest request = new GetFieldRequest { FieldName = new FieldName("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[FIELD_ID]"), }; apis::Field expectedResponse = new apis::Field { Name = "name2-1052831874", }; mockGrpcClient.Setup(x => x.GetFieldAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <apis::Field>(Task.FromResult(expectedResponse), null, null, null, null)); FirestoreAdminClient client = new FirestoreAdminClientImpl(mockGrpcClient.Object, null); apis::Field response = await client.GetFieldAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetField2() { Mock <FirestoreAdmin.FirestoreAdminClient> mockGrpcClient = new Mock <FirestoreAdmin.FirestoreAdminClient>(MockBehavior.Strict); GetFieldRequest request = new GetFieldRequest { FieldName = new FieldName("[PROJECT]", "[DATABASE]", "[COLLECTION_ID]", "[FIELD_ID]"), }; apis::Field expectedResponse = new apis::Field { Name = "name2-1052831874", }; mockGrpcClient.Setup(x => x.GetField(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); FirestoreAdminClient client = new FirestoreAdminClientImpl(mockGrpcClient.Object, null); apis::Field response = client.GetField(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void TestSearchFieldByAlias() { var request = SearchFieldRequest.Builder() .AddField(HRBCField.FieldProperty.Resource) .AddField(HRBCField.FieldProperty.Alias) .AddField(HRBCField.Properties.All) .Resource(ResourceId.Job) .Alias("P_MinSalary"); TestContext.Out.WriteLine("Start to send a request for searching !"); Task <SearchFieldResponseData> result = session.CallAsync(request.GetRequest()); TestContext.Out.WriteLine("Take a cup of coffee in meantime!"); SearchFieldResponseData response = result.Result; TestContext.Out.WriteLine("Start to get the result !"); Assert.That(response, Is.Not.Null, "Response data is null!"); Assert.That(response.Result, Is.Not.Null, "Id is null!"); Assert.That(response.Result.Count, Is.GreaterThan(0), "Count is 0!"); var temp = from field in response.Result select field.Id as string; TestContext.Out.WriteLine("Start to send a request for searching 123 = {0}!", temp.ToArray()[0]); var getRequest = GetFieldRequest.Builder() .AddIds(temp.ToArray()) .AddField(HRBCField.FieldProperty.Resource) .AddField(HRBCField.FieldProperty.Alias) .AddField(HRBCField.Properties.All); Task <GetFieldResponseData> task = session.CallAsync(getRequest.GetRequest()); TestContext.Out.WriteLine("Take the second cup of coffee in meantime!"); GetFieldResponseData fieldData = task.Result; Assert.That(fieldData, Is.Not.Null, "Response data is null!"); Assert.That(fieldData.Values.First().Value.Resource, Is.EqualTo("job"), "Wrong resource type!"); }
public void TestGetFieldWithoutNodePath() { string localFileName = "GetField.docx"; string remoteFileName = "TestGetFieldWithoutNodePath.docx"; this.UploadFileToStorage( remoteDataFolder + "/" + remoteFileName, null, null, File.ReadAllBytes(LocalTestDataFolder + fieldFolder + "/" + localFileName) ); var request = new GetFieldRequest( name: remoteFileName, index: 0, folder: remoteDataFolder ); var actual = this.WordsApi.GetField(request); Assert.NotNull(actual.Field); Assert.AreEqual("1", actual.Field.Result); }
protected override void ProcessRecord() { base.ProcessRecord(); GetFieldRequest request; try { request = new GetFieldRequest { NamespaceName = NamespaceName, FieldName = FieldName, OpcRequestId = OpcRequestId }; response = client.GetField(request).GetAwaiter().GetResult(); WriteOutput(response, response.LogAnalyticsField); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }