public async stt::Task GetRegistrationResourceNamesAsync() { moq::Mock <Domains.DomainsClient> mockGrpcClient = new moq::Mock <Domains.DomainsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetRegistrationRequest request = new GetRegistrationRequest { RegistrationName = RegistrationName.FromProjectLocationRegistration("[PROJECT]", "[LOCATION]", "[REGISTRATION]"), }; Registration expectedResponse = new Registration { RegistrationName = RegistrationName.FromProjectLocationRegistration("[PROJECT]", "[LOCATION]", "[REGISTRATION]"), DomainName = "domain_nameea17a44f", CreateTime = new wkt::Timestamp(), ExpireTime = new wkt::Timestamp(), State = Registration.Types.State.Unspecified, Issues = { Registration.Types.Issue.UnverifiedEmail, }, Labels = { { "key8a0b6e3c", "value60c16320" }, }, ManagementSettings = new ManagementSettings(), DnsSettings = new DnsSettings(), ContactSettings = new ContactSettings(), PendingContactSettings = new ContactSettings(), SupportedPrivacy = { ContactPrivacy.PublicContactData, }, }; mockGrpcClient.Setup(x => x.GetRegistrationAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Registration>(stt::Task.FromResult(expectedResponse), null, null, null, null)); DomainsClient client = new DomainsClientImpl(mockGrpcClient.Object, null); Registration responseCallSettings = await client.GetRegistrationAsync(request.RegistrationName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Registration responseCancellationToken = await client.GetRegistrationAsync(request.RegistrationName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void ResetAuthorizationCodeResourceNames() { moq::Mock <Domains.DomainsClient> mockGrpcClient = new moq::Mock <Domains.DomainsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); ResetAuthorizationCodeRequest request = new ResetAuthorizationCodeRequest { RegistrationAsRegistrationName = RegistrationName.FromProjectLocationRegistration("[PROJECT]", "[LOCATION]", "[REGISTRATION]"), }; AuthorizationCode expectedResponse = new AuthorizationCode { Code = "code946733c1", }; mockGrpcClient.Setup(x => x.ResetAuthorizationCode(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); DomainsClient client = new DomainsClientImpl(mockGrpcClient.Object, null); AuthorizationCode response = client.ResetAuthorizationCode(request.RegistrationAsRegistrationName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void RetrieveRegisterParametersResourceNames() { moq::Mock <Domains.DomainsClient> mockGrpcClient = new moq::Mock <Domains.DomainsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); RetrieveRegisterParametersRequest request = new RetrieveRegisterParametersRequest { DomainName = "domain_nameea17a44f", LocationAsLocationName = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), }; RetrieveRegisterParametersResponse expectedResponse = new RetrieveRegisterParametersResponse { RegisterParameters = new RegisterParameters(), }; mockGrpcClient.Setup(x => x.RetrieveRegisterParameters(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); DomainsClient client = new DomainsClientImpl(mockGrpcClient.Object, null); RetrieveRegisterParametersResponse response = client.RetrieveRegisterParameters(request.LocationAsLocationName, request.DomainName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task ResetAuthorizationCodeResourceNamesAsync() { moq::Mock <Domains.DomainsClient> mockGrpcClient = new moq::Mock <Domains.DomainsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); ResetAuthorizationCodeRequest request = new ResetAuthorizationCodeRequest { RegistrationAsRegistrationName = RegistrationName.FromProjectLocationRegistration("[PROJECT]", "[LOCATION]", "[REGISTRATION]"), }; AuthorizationCode expectedResponse = new AuthorizationCode { Code = "code946733c1", }; mockGrpcClient.Setup(x => x.ResetAuthorizationCodeAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <AuthorizationCode>(stt::Task.FromResult(expectedResponse), null, null, null, null)); DomainsClient client = new DomainsClientImpl(mockGrpcClient.Object, null); AuthorizationCode responseCallSettings = await client.ResetAuthorizationCodeAsync(request.RegistrationAsRegistrationName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); AuthorizationCode responseCancellationToken = await client.ResetAuthorizationCodeAsync(request.RegistrationAsRegistrationName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }