public async stt::Task GetCatalogItemResourceNamesAsync()
        {
            moq::Mock <CatalogService.CatalogServiceClient> mockGrpcClient = new moq::Mock <CatalogService.CatalogServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetCatalogItemRequest request = new GetCatalogItemRequest
            {
                CatalogItemPathName = CatalogItemPathName.FromProjectLocationCatalogCatalogItemPath("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CATALOG_ITEM_PATH]"),
            };
            CatalogItem expectedResponse = new CatalogItem
            {
                Id = "id74b70bb8",
                CategoryHierarchies =
                {
                    new CatalogItem.Types.CategoryHierarchy(),
                },
                Title           = "title17dbd3d5",
                Description     = "description2cf9da67",
                ItemAttributes  = new FeatureMap(),
                LanguageCode    = "language_code2f6c7160",
                Tags            = { "tags52c47ad5", },
                ItemGroupId     = "item_group_id08a4c0f5",
                ProductMetadata = new ProductCatalogItem(),
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            CatalogItem responseCancellationToken = await client.GetCatalogItemAsync(request.CatalogItemPathName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
 public Returns
 (
     WebApplicationFactory <Startup> aWebApplicationFactory,
     JsonSerializerOptions aJsonSerializerOptions
 ) : base(aWebApplicationFactory, aJsonSerializerOptions)
 {
     GetCatalogItemRequest = new GetCatalogItemRequest {
         CatalogItemId = 10
     };
 }
        public void Be_Valid()
        {
            var getCatalogItemRequest = new GetCatalogItemRequest
            {
                // Set Valid values here
                CatalogItemId = 3
            };

            ValidationResult validationResult = GetCatalogItemRequestValidator.TestValidate(getCatalogItemRequest);

            validationResult.IsValid.Should().BeTrue();
        }
 /// <summary>Snippet for GetCatalogItem</summary>
 public void GetCatalogItemRequestObject()
 {
     // Snippet: GetCatalogItem(GetCatalogItemRequest, CallSettings)
     // Create client
     CatalogServiceClient catalogServiceClient = CatalogServiceClient.Create();
     // Initialize request argument(s)
     GetCatalogItemRequest request = new GetCatalogItemRequest
     {
         CatalogItemPathName = CatalogItemPathName.FromProjectLocationCatalogCatalogItemPath("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CATALOG_ITEM_PATH]"),
     };
     // Make the request
     CatalogItem response = catalogServiceClient.GetCatalogItem(request);
     // End snippet
 }
        /// <summary>Snippet for GetCatalogItemAsync</summary>
        public async Task GetCatalogItemRequestObjectAsync()
        {
            // Snippet: GetCatalogItemAsync(GetCatalogItemRequest, CallSettings)
            // Additional: GetCatalogItemAsync(GetCatalogItemRequest, CancellationToken)
            // Create client
            CatalogServiceClient catalogServiceClient = await CatalogServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetCatalogItemRequest request = new GetCatalogItemRequest
            {
                CatalogItemPathName = CatalogItemPathName.FromProjectLocationCatalogCatalogItemPath("[PROJECT]", "[LOCATION]", "[CATALOG]", "[CATALOG_ITEM_PATH]"),
            };
            // Make the request
            CatalogItem response = await catalogServiceClient.GetCatalogItemAsync(request);

            // End snippet
        }
Beispiel #6
0
        public static CatalogItemDetails GetCatalogItem(string catalogID, string accountItemID)
        {
            CatalogItemDetails details = null;

            try
            {
                using (_certonaService = new CertonaServiceClient())
                {
                    try
                    {
                        UserDTO user = FormsAuthenticationWrapper.User;
                        var     catalogItemRequest = new GetCatalogItemRequest()
                        {
                            User          = user,
                            AccountID     = user.LastAccountID,
                            AccountItemID = accountItemID,
                            CatalogID     = catalogID
                        };

                        var catalogItemResponse = _certonaService.GetCatalogItem(catalogItemRequest);

                        if (catalogItemResponse.Success && catalogItemResponse.CatalogItem != null)
                        {
                            details = new CatalogItemDetails()
                            {
                                CatalogAssociatedItems = catalogItemResponse.CatalogItem.CatalogItemAssociatedItem.Select(
                                    r => new ItemAssociatedItem
                                {
                                    ItemID       = r.ItemID,
                                    DisplayOrder = r.DisplayOrder
                                }).ToList()
                            };

                            if (catalogItemResponse.CatalogItem.CatalogItemInfo != null)
                            {
                                details.CatalogItemInfo = new ItemInfo(catalogItemResponse.CatalogItem.CatalogItemInfo);
                            }

                            details.CatalogItemMetaData = catalogItemResponse.CatalogItem.CatalogItemMetaData.Select(
                                r => new ItemMetaData
                            {
                                CatalogID    = r.CatalogID,
                                FunctionName = r.FunctionName,
                                LevelName    = r.LevelName,
                                GroupName    = r.GroupName
                            }).ToList();

                            details.CatalogMetaData = catalogItemResponse.CatalogItem.CatalogMetaData.Select(
                                r => new MetaData
                            {
                                CatalogID = r.CatalogID,
                                Name1     = r.Name1,
                                Name2     = r.Name2,
                                Name3     = r.Name3
                            }).ToList();

                            details.CatalogMetaData2 = catalogItemResponse.CatalogItem.CatalogMetaData2.Select(
                                r => new MetaData
                            {
                                CatalogID = r.CatalogID,
                                Name1     = r.Name1,
                                Name2     = r.Name2,
                                Name3     = r.Name3
                            }).ToList();

                            details.CatalogMapping = catalogItemResponse.CatalogItem.CatalogMapping.Select(
                                r => new CatalogMapping
                            {
                                CatalogID      = r.CatalogID,
                                ResonanceField = r.ResonanceField,
                                CustomerField  = r.CustomerField,
                                Description    = r.Description,
                                AttributeType  = r.AttributeType,
                                CustomVariable = r.CustomVariable,
                                IsRuleEnabled  = r.IsRuleEnabled,
                                IsMapped       = r.IsMapped,
                                XSLTransform   = r.XSLTransform,
                                OLAPLevel      = r.OLAPLevel
                            }).ToList();
                        }
                    }
                    catch (TimeoutException exception)
                    {
                        _certonaService.Abort();
                        throw;
                    }
                    catch (CommunicationException exception)
                    {
                        _certonaService.Abort();
                        throw;
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(details);
        }