Example #1
0
        public static Dictionary <string, ExchangeMappingProperties> GetExchangeMapping(string mode)
        {
            var mappingProperties = new Dictionary <string, ExchangeMappingProperties>()
            {
            };

            foreach (string resource in Enum.GetNames(typeof(TestCoreFramework.Enums.ResourceType)))
            {
                var resourceName = resource == TestCoreFramework.Enums.ResourceType.Candidate.ToString() ? "Person" : resource;
                mappingProperties.Add(resourceName, ExchangeMappingProperties.GetMappingContent(
                                          mode.ToLower(),
                                          0,
                                          $"{LabelName}{resource}",
                                          $"{LabelName}{resource}",
                                          resource,
                                          resource,
                                          mode == Mode.Import.ToString() ? new List <string> {
                    $"{resourceName}.P_Id"
                } : null,
                                          GetLabels(mode, resourceName),
                                          GetGroups(mode, resourceName),
                                          GetItems(mode, resourceName),
                                          GetConverters(mode, resourceName),
                                          mode == Mode.Export.ToString() ? new List <string>()
                {
                    "10001"
                } : null));
            }

            return(mappingProperties);
        }
Example #2
0
        public void ExchangeMappingInvalidContentTest(string mode, ContentParam contentParam, InvalidContent invalidContent, int expectedCode)
        {
            ExchangeMappingProperties requestBody = ExchangeMappingProperties.GetMappingContent(mode, mode == "import" ? CreatedImportMapping.Data : CreatedExportMapping.Data, Label, Name, Group, Resource, new List <string> {
                "Client.P_Id"
            }, Labels, GroupsDic, Items, AdditionConverters);
            var mappingHandler = new MappingManager();
            var response       = mappingHandler.ExchangeMapping <object>(InvalidContentMapper[contentParam](requestBody, invalidContent), System.Net.Http.HttpMethod.Put);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(System.Net.HttpStatusCode.BadRequest).And.ErrorCode(100).Or.ErrorCode(116).Or.ErrorCode(103));
        }
Example #3
0
        private void SendRequestAndVerify(string mode, Func <ExchangeMappingProperties, IEnumerable <KeyValuePair <string, object> > > getRequest, System.Net.HttpStatusCode statusCode, int expectedCode)
        {
            ExchangeMappingProperties requestBody = ExchangeMappingProperties.GetMappingContent(mode, mode == "import" ? CreatedImportMapping.Data : CreatedExportMapping.Data, Label, Name, Group, Resource, new List <string> {
                "Client.P_Id"
            }, Labels, GroupsDic, Items, AdditionConverters);
            var mappingHandler = new MappingManager();
            var response       = mappingHandler.ExchangeMapping <object>(getRequest(requestBody), System.Net.Http.HttpMethod.Put);

            PrAssert.That(response, PrIs.ErrorResponse().And.HttpCode(statusCode).And.ErrorCode(expectedCode));
        }
Example #4
0
        public static ExchangeMappingProperties GetDefaultExchangeMapping(Common.Mode mode, ResourceId resourceId, int mappingId = 0)
        {
            string resourceName = resourceId == ResourceId.Person ? "candidate" : resourceId.ToString().ToLower();

            return(mode == Common.Mode.Import ? ExchangeMappingProperties.GetMappingContent(mode.ToString().ToLower(), mappingId, "label", "name", resourceName, resourceName, Common.GetDefaultKeys(resourceId),
                                                                                            Common.GetDefaultImportLabels(),
                                                                                            Common.GetDefaultImportGroups(resourceId),
                                                                                            Common.GetDefaultImportItems(), Common.GetDefaultImportConverters()) :
                   ExchangeMappingProperties.GetMappingContent(mode.ToString().ToLower(), mappingId, "label", "name", resourceName, resourceName, new List <string> {
            },
                                                               Common.GetDefaultExportLabels(),
                                                               Common.GetDefaultExportGroups(resourceId),
                                                               Common.GetDefaultExportItems(resourceId), Common.GetDefaultExportConverters()));
        }
Example #5
0
        public static Dictionary <string, object> RequestValidExchangeMappingUpdate(int id, Label label, Scope scope, ExchangeMappingProperties mappingContent)
        {
            var dict = new Dictionary <string, object>()
            {
                [Params.Id.ToString().ToLower()]      = id,
                [Params.Label.ToString().ToLower()]   = GetLabel(label),
                [Params.Content.ToString().ToLower()] = mappingContent.Content,
            };

            if (scope != Scope.Null)
            {
                dict[Params.Scope.ToString().ToLower()] = scope.ToString().ToLower();
            }

            return(dict);
        }
Example #6
0
        private static IEnumerable <KeyValuePair <string, object> > GetExpectedContentDictionary(ExchangeMappingProperties p, InvalidContent i, string contentItem)
        {
            var dic     = ConvertToDictionary(p);
            var content = ConvertToDictionary(dic["content"]);

            if (i == InvalidContent.Empty)
            {
                content[contentItem] = "";
            }
            else if (i == InvalidContent.Null)
            {
                content.Remove(contentItem);
            }
            dic["content"] = content;
            return(dic);
        }