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();
        }
Пример #2
0
        public void CreateGroup2()
        {
            Mock <GroupService.GroupServiceClient> mockGrpcClient = new Mock <GroupService.GroupServiceClient>(MockBehavior.Strict);
            CreateGroupRequest request = new CreateGroupRequest
            {
                ProjectName = new ProjectName("[PROJECT]"),
                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.CreateGroup(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            GroupServiceClient client = new GroupServiceClientImpl(mockGrpcClient.Object, null);
            Group response            = client.CreateGroup(request);

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