public async stt::Task GenerateConnectManifestRequestObjectAsync() { moq::Mock <GkeHub.GkeHubClient> mockGrpcClient = new moq::Mock <GkeHub.GkeHubClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GenerateConnectManifestRequest request = new GenerateConnectManifestRequest { MembershipName = MembershipName.FromProjectLocationMembership("[PROJECT]", "[LOCATION]", "[MEMBERSHIP]"), Namespace = "namespace9e1e8089", Proxy = proto::ByteString.CopyFromUtf8("proxyeb871343"), Version = "version102ff72a", IsUpgrade = false, Registry = "registrycf5d20a9", ImagePullSecretContent = proto::ByteString.CopyFromUtf8("image_pull_secret_content89fc8e49"), }; GenerateConnectManifestResponse expectedResponse = new GenerateConnectManifestResponse { Manifest = { new ConnectAgentResource(), }, }; mockGrpcClient.Setup(x => x.GenerateConnectManifestAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <GenerateConnectManifestResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); GkeHubClient client = new GkeHubClientImpl(mockGrpcClient.Object, null); GenerateConnectManifestResponse responseCallSettings = await client.GenerateConnectManifestAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); GenerateConnectManifestResponse responseCancellationToken = await client.GenerateConnectManifestAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async stt::Task GetMembershipRequestObjectAsync() { moq::Mock <GkeHubMembershipService.GkeHubMembershipServiceClient> mockGrpcClient = new moq::Mock <GkeHubMembershipService.GkeHubMembershipServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetMembershipRequest request = new GetMembershipRequest { Name = "name1c9368b0", }; Membership expectedResponse = new Membership { MembershipName = MembershipName.FromProjectLocationMembership("[PROJECT]", "[LOCATION]", "[MEMBERSHIP]"), Labels = { { "key8a0b6e3c", "value60c16320" }, }, Description = "description2cf9da67", Endpoint = new MembershipEndpoint(), State = new MembershipState(), CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), DeleteTime = new wkt::Timestamp(), Authority = new Authority(), ExternalId = "external_id9442680e", LastConnectionTime = new wkt::Timestamp(), UniqueId = "unique_idee0c0869", InfrastructureType = Membership.Types.InfrastructureType.Unspecified, }; mockGrpcClient.Setup(x => x.GetMembershipAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Membership>(stt::Task.FromResult(expectedResponse), null, null, null, null)); GkeHubMembershipServiceClient client = new GkeHubMembershipServiceClientImpl(mockGrpcClient.Object, null); Membership responseCallSettings = await client.GetMembershipAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Membership responseCancellationToken = await client.GetMembershipAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetMembershipRequestObject() { moq::Mock <GkeHub.GkeHubClient> mockGrpcClient = new moq::Mock <GkeHub.GkeHubClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetMembershipRequest request = new GetMembershipRequest { MembershipName = MembershipName.FromProjectLocationMembership("[PROJECT]", "[LOCATION]", "[MEMBERSHIP]"), }; Membership expectedResponse = new Membership { MembershipName = MembershipName.FromProjectLocationMembership("[PROJECT]", "[LOCATION]", "[MEMBERSHIP]"), Labels = { { "key8a0b6e3c", "value60c16320" }, }, Description = "description2cf9da67", Endpoint = new MembershipEndpoint(), State = new MembershipState(), CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), DeleteTime = new wkt::Timestamp(), ExternalId = "external_id9442680e", LastConnectionTime = new wkt::Timestamp(), UniqueId = "unique_idee0c0869", Authority = new Authority(), }; mockGrpcClient.Setup(x => x.GetMembership(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); GkeHubClient client = new GkeHubClientImpl(mockGrpcClient.Object, null); Membership response = client.GetMembership(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }