Пример #1
0
        public void GetGroup()
        {
            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.GetGroup(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            GroupServiceClient client = new GroupServiceClientImpl(mockGrpcClient.Object, null);
            GroupName          name   = new GroupName("[PROJECT]", "[GROUP]");
            Group response            = client.GetGroup(name);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void GetGroup()
        {
            moq::Mock <GroupService.GroupServiceClient> mockGrpcClient = new moq::Mock <GroupService.GroupServiceClient>(moq::MockBehavior.Strict);
            GetGroupRequest request = new GetGroupRequest
            {
                GroupName = GroupName.FromProjectGroup("[PROJECT]", "[GROUP]"),
            };
            Group expectedResponse = new Group
            {
                GroupName   = GroupName.FromProjectGroup("[PROJECT]", "[GROUP]"),
                DisplayName = "display_name137f65c2",
                ParentName  = "parent_name91315215",
                Filter      = "filtere47ac9b2",
                IsCluster   = true,
            };

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

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }