public async stt::Task GetDomainAsync_ResourceNames() { moq::Mock <ManagedIdentitiesService.ManagedIdentitiesServiceClient> mockGrpcClient = new moq::Mock <ManagedIdentitiesService.ManagedIdentitiesServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetDomainRequest request = new GetDomainRequest { DomainName = new DomainName("[PROJECT]", "[LOCATION]", "[DOMAIN]"), }; Domain expectedResponse = new Domain { DomainName = new DomainName("[PROJECT]", "[LOCATION]", "[DOMAIN]"), Labels = { { "key8a0b6e3c", "value60c16320" }, }, AuthorizedNetworks = { "authorized_networksfe43416a", }, ReservedIpRange = "reserved_ip_range779ab299", Locations = { "locationsc7b6c0b4", }, Admin = "admin292f2321", Fqdn = "fqdnc75d2ea0", CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), State = Domain.Types.State.PerformingMaintenance, StatusMessage = "status_message2c618f86", Trusts = { new Trust(), }, }; mockGrpcClient.Setup(x => x.GetDomainAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Domain>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ManagedIdentitiesServiceClient client = new ManagedIdentitiesServiceClientImpl(mockGrpcClient.Object, null); Domain responseCallSettings = await client.GetDomainAsync(request.DomainName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Domain responseCancellationToken = await client.GetDomainAsync(request.DomainName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void ResetAdminPassword() { moq::Mock <ManagedIdentitiesService.ManagedIdentitiesServiceClient> mockGrpcClient = new moq::Mock <ManagedIdentitiesService.ManagedIdentitiesServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); ResetAdminPasswordRequest request = new ResetAdminPasswordRequest { DomainName = new DomainName("[PROJECT]", "[LOCATION]", "[DOMAIN]"), }; ResetAdminPasswordResponse expectedResponse = new ResetAdminPasswordResponse { Password = "******", }; mockGrpcClient.Setup(x => x.ResetAdminPassword(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); ManagedIdentitiesServiceClient client = new ManagedIdentitiesServiceClientImpl(mockGrpcClient.Object, null); ResetAdminPasswordResponse response = client.ResetAdminPassword(request.Name); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task ResetAdminPasswordRequestObjectAsync() { moq::Mock <ManagedIdentitiesService.ManagedIdentitiesServiceClient> mockGrpcClient = new moq::Mock <ManagedIdentitiesService.ManagedIdentitiesServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); ResetAdminPasswordRequest request = new ResetAdminPasswordRequest { DomainName = new DomainName("[PROJECT]", "[LOCATION]", "[DOMAIN]"), }; ResetAdminPasswordResponse expectedResponse = new ResetAdminPasswordResponse { Password = "******", }; mockGrpcClient.Setup(x => x.ResetAdminPasswordAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ResetAdminPasswordResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ManagedIdentitiesServiceClient client = new ManagedIdentitiesServiceClientImpl(mockGrpcClient.Object, null); ResetAdminPasswordResponse responseCallSettings = await client.ResetAdminPasswordAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); ResetAdminPasswordResponse responseCancellationToken = await client.ResetAdminPasswordAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }