public void Insert() { moq::Mock <Licenses.LicensesClient> mockGrpcClient = new moq::Mock <Licenses.LicensesClient>(moq::MockBehavior.Strict); InsertLicenseRequest request = new InsertLicenseRequest { Project = "projectaa6ff846", LicenseResource = new License(), }; Operation expectedResponse = new Operation { Id = 11672635353343658936UL, Kind = "kindf7aa39d9", Name = "name1c9368b0", User = "******", Zone = "zone255f4ea8", CreationTimestamp = "creation_timestamp235e59a1", StartTime = "start_timebd8dd9c4", OperationGroupId = "operation_group_idd2040cf0", TargetLink = "target_link9b435dc0", Progress = 278622268, Error = new Error(), EndTime = "end_time89285d30", Region = "regionedb20d96", OperationType = "operation_typeece9e153", Status = Operation.Types.Status.Pending, HttpErrorMessage = "http_error_messageb5ef3c7f", TargetId = 6263187990225347157UL, ClientOperationId = "client_operation_id4e51b631", StatusMessage = "status_message2c618f86", HttpErrorStatusCode = 1766362655, Description = "description2cf9da67", InsertTime = "insert_time7467185a", SelfLink = "self_link7e87f12d", Warnings = { new Warnings(), }, }; mockGrpcClient.Setup(x => x.Insert(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); LicensesClient client = new LicensesClientImpl(mockGrpcClient.Object, null); Operation response = client.Insert(request.Project, request.LicenseResource); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void List() { moq::Mock <Licenses.LicensesClient> mockGrpcClient = new moq::Mock <Licenses.LicensesClient>(moq::MockBehavior.Strict); ListLicensesRequest request = new ListLicensesRequest { Project = "projectaa6ff846", }; LicensesListResponse expectedResponse = new LicensesListResponse { Id = "id74b70bb8", Warning = new Warning(), NextPageToken = "next_page_tokendbee0940", Items = { new License(), }, SelfLink = "self_link7e87f12d", }; mockGrpcClient.Setup(x => x.List(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); LicensesClient client = new LicensesClientImpl(mockGrpcClient.Object, null); LicensesListResponse response = client.List(request.Project); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void TestIamPermissions() { moq::Mock <Licenses.LicensesClient> mockGrpcClient = new moq::Mock <Licenses.LicensesClient>(moq::MockBehavior.Strict); TestIamPermissionsLicenseRequest request = new TestIamPermissionsLicenseRequest { Resource = "resource164eab96", Project = "projectaa6ff846", TestPermissionsRequestResource = new TestPermissionsRequest(), }; TestPermissionsResponse expectedResponse = new TestPermissionsResponse { Permissions = { "permissions535a2741", }, }; mockGrpcClient.Setup(x => x.TestIamPermissions(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); LicensesClient client = new LicensesClientImpl(mockGrpcClient.Object, null); TestPermissionsResponse response = client.TestIamPermissions(request.Project, request.Resource, request.TestPermissionsRequestResource); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }