public async stt::Task UpdateGroupAsync()
        {
            moq::Mock <GroupService.GroupServiceClient> mockGrpcClient = new moq::Mock <GroupService.GroupServiceClient>(moq::MockBehavior.Strict);
            UpdateGroupRequest request = new UpdateGroupRequest {
                Group = new Group(),
            };
            Group expectedResponse = new Group
            {
                GroupName   = GroupName.FromProjectGroup("[PROJECT]", "[GROUP]"),
                DisplayName = "display_name137f65c2",
                ParentName  = "parent_name91315215",
                Filter      = "filtere47ac9b2",
                IsCluster   = true,
            };

            mockGrpcClient.Setup(x => x.UpdateGroupAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Group>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            GroupServiceClient client  = new GroupServiceClientImpl(mockGrpcClient.Object, null);
            Group responseCallSettings = await client.UpdateGroupAsync(request.Group, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Group responseCancellationToken = await client.UpdateGroupAsync(request.Group, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void CreateGroupRequestObject()
        {
            moq::Mock <GroupService.GroupServiceClient> mockGrpcClient = new moq::Mock <GroupService.GroupServiceClient>(moq::MockBehavior.Strict);
            CreateGroupRequest request = new CreateGroupRequest
            {
                Group        = new Group(),
                ValidateOnly = true,
                ProjectName  = gagr::ProjectName.FromProject("[PROJECT]"),
            };
            Group expectedResponse = new Group
            {
                GroupName   = GroupName.FromProjectGroup("[PROJECT]", "[GROUP]"),
                DisplayName = "display_name137f65c2",
                ParentName  = "parent_name91315215",
                Filter      = "filtere47ac9b2",
                IsCluster   = true,
            };

            mockGrpcClient.Setup(x => x.CreateGroup(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            GroupServiceClient client = new GroupServiceClientImpl(mockGrpcClient.Object, null);
            Group response            = client.CreateGroup(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #3
0
        public async Task GetGroupAsync()
        {
            Mock <GroupService.GroupServiceClient> mockGrpcClient = new Mock <GroupService.GroupServiceClient>(MockBehavior.Strict);
            GetGroupRequest expectedRequest = new GetGroupRequest
            {
                GroupName = new GroupName("[PROJECT]", "[GROUP]"),
            };
            Group expectedResponse = new Group
            {
                GroupName             = new GroupName("[PROJECT]", "[GROUP]"),
                DisplayName           = "displayName1615086568",
                ParentNameAsGroupName = new GroupName("[PROJECT]", "[GROUP]"),
                Filter    = "filter-1274492040",
                IsCluster = false,
            };

            mockGrpcClient.Setup(x => x.GetGroupAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Group>(Task.FromResult(expectedResponse), null, null, null, null));
            GroupServiceClient client = new GroupServiceClientImpl(mockGrpcClient.Object, null);
            GroupName          name   = new GroupName("[PROJECT]", "[GROUP]");
            Group response            = await client.GetGroupAsync(name);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #4
0
        public void UpdateGroup()
        {
            Mock <GroupService.GroupServiceClient> mockGrpcClient = new Mock <GroupService.GroupServiceClient>(MockBehavior.Strict);
            UpdateGroupRequest expectedRequest = new UpdateGroupRequest
            {
                Group = new Group(),
            };
            Group expectedResponse = new Group
            {
                GroupName             = new GroupName("[PROJECT]", "[GROUP]"),
                DisplayName           = "displayName1615086568",
                ParentNameAsGroupName = new GroupName("[PROJECT]", "[GROUP]"),
                Filter    = "filter-1274492040",
                IsCluster = false,
            };

            mockGrpcClient.Setup(x => x.UpdateGroup(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            GroupServiceClient client = new GroupServiceClientImpl(mockGrpcClient.Object, null);
            Group group    = new Group();
            Group response = client.UpdateGroup(group);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void DeleteGroupResourceNames2()
        {
            moq::Mock <GroupService.GroupServiceClient> mockGrpcClient = new moq::Mock <GroupService.GroupServiceClient>(moq::MockBehavior.Strict);
            DeleteGroupRequest request = new DeleteGroupRequest
            {
                GroupName = GroupName.FromProjectGroup("[PROJECT]", "[GROUP]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.DeleteGroup(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            GroupServiceClient client = new GroupServiceClientImpl(mockGrpcClient.Object, null);

            client.DeleteGroup(request.ResourceName);
            mockGrpcClient.VerifyAll();
        }
예제 #6
0
        public async Task DeleteGroupAsync2()
        {
            Mock <GroupService.GroupServiceClient> mockGrpcClient = new Mock <GroupService.GroupServiceClient>(MockBehavior.Strict);
            DeleteGroupRequest request = new DeleteGroupRequest
            {
                GroupName = new GroupName("[PROJECT]", "[GROUP]"),
            };
            Empty expectedResponse = new Empty();

            mockGrpcClient.Setup(x => x.DeleteGroupAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Empty>(Task.FromResult(expectedResponse), null, null, null, null));
            GroupServiceClient client = new GroupServiceClientImpl(mockGrpcClient.Object, null);
            await client.DeleteGroupAsync(request);

            mockGrpcClient.VerifyAll();
        }
예제 #7
0
        public void DeleteGroup2()
        {
            Mock <GroupService.GroupServiceClient> mockGrpcClient = new Mock <GroupService.GroupServiceClient>(MockBehavior.Strict);
            DeleteGroupRequest request = new DeleteGroupRequest
            {
                GroupName = new GroupName("[PROJECT]", "[GROUP]"),
            };
            Empty expectedResponse = new Empty();

            mockGrpcClient.Setup(x => x.DeleteGroup(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            GroupServiceClient client = new GroupServiceClientImpl(mockGrpcClient.Object, null);

            client.DeleteGroup(request);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task DeleteGroupResourceNames2Async()
        {
            moq::Mock <GroupService.GroupServiceClient> mockGrpcClient = new moq::Mock <GroupService.GroupServiceClient>(moq::MockBehavior.Strict);
            DeleteGroupRequest request = new DeleteGroupRequest
            {
                GroupName = GroupName.FromProjectGroup("[PROJECT]", "[GROUP]"),
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.DeleteGroupAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            GroupServiceClient client = new GroupServiceClientImpl(mockGrpcClient.Object, null);
            await client.DeleteGroupAsync(request.ResourceName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            await client.DeleteGroupAsync(request.ResourceName, st::CancellationToken.None);

            mockGrpcClient.VerifyAll();
        }