예제 #1
0
        /// <summary>
        /// Delivery an MDM entity as a data contract for a mapping request
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ContractResponse <TContract> Map(MappingRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            if (request.IsNexusMappingRequest())
            {
                if (request.HasNumericIdentifier())
                {
                    return(this.Request(request.ToGetRequest()));
                }
                else
                {
                    var response = this.ContractResponse(null, request.ValidAt, request.Version);
                    response.Error.Reason = ErrorReason.Identifier;
                    return(response);
                }
            }

            this.Validate(request);

            var mapping = this.repository.FindAllMappings <TMapping>(request).FirstOrDefault(m => m.Entity is TEntity);

            if (mapping == null)
            {
                var response = ContractResponse(null, request.ValidAt, request.Version);
                response.Error.Reason = ErrorReason.Identifier;
                return(response);
            }
            return(ContractResponse(mapping.Entity as TEntity, request.ValidAt, request.Version));
        }
        public void HasNumericIdentifier_WithNaN_ReturnsTrue()
        {
            var mappingRequest = new MappingRequest {
                SystemName = SourceSystemNames.Nexus, Identifier = "string"
            };

            Assert.IsFalse(mappingRequest.HasNumericIdentifier());
        }
        public void HasNumericIdentifier_WithInteger_ReturnsTrue()
        {
            var mappingRequest = new MappingRequest {
                SystemName = SourceSystemNames.Nexus, Identifier = "999"
            };

            Assert.IsTrue(mappingRequest.HasNumericIdentifier());
        }
 public void HasNumericIdentifier_WithNaN_ReturnsTrue()
 {
     var mappingRequest = new MappingRequest { SystemName = SourceSystemNames.Nexus, Identifier = "string" };
     Assert.IsFalse(mappingRequest.HasNumericIdentifier());
 }
 public void HasNumericIdentifier_WithInteger_ReturnsTrue()
 {
     var mappingRequest = new MappingRequest { SystemName = SourceSystemNames.Nexus, Identifier = "999" };
     Assert.IsTrue(mappingRequest.HasNumericIdentifier());
 }