Ejemplo n.º 1
0
        public void op_ToString(string address1,
                                string address2,
                                string address3,
                                string address4,
                                string address5,
                                string address6,
                                string postcode,
                                string expected)
        {
            var obj = new MarketingAddress
            {
                Address1 = address1,
                Address2 = address2,
                Address3 = address3,
                Address4 = address4,
                Address5 = address5,
                Address6 = address6,
                Postcode = postcode
            };

            var actual = obj.FullAddress;

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 2
0
        public void op_ToString(string address1,
                                string address2,
                                string address3,
                                string address4,
                                string address5,
                                string address6,
                                string postcode,
                                string expected)
        {
            var obj = new MarketingAddress
                          {
                              Address1 = address1,
                              Address2 = address2,
                              Address3 = address3,
                              Address4 = address4,
                              Address5 = address5,
                              Address6 = address6,
                              Postcode = postcode
                          };

            var actual = obj.FullAddress;

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 3
0
        public static MarketingAddress ToMarketingFormat(KeyStringDictionary entry)
        {
            if (null == entry)
            {
                throw new ArgumentNullException("entry");
            }

            var clone  = entry.Clone <KeyStringDictionary>();
            var result = new MarketingAddress
            {
                { "ADDRESS 1", string.Empty },
                { "ADDRESS 2", string.Empty },
                { "ADDRESS 3", string.Empty },
                { "ADDRESS 4", string.Empty },
                { "ADDRESS 5", string.Empty },
                { "ADDRESS 6", string.Empty },
                { "POSTCODE", clone["PCD"] },
            };

            if (clone["SBN"].ContainsText())
            {
                result["ADDRESS 1"] = clone["SBN"];
            }

            if (clone["BNA"].ContainsText())
            {
                foreach (var column in "ADDRESS 1,ADDRESS 2".Split(',')
                         .Where(column => result[column].IsEmpty()))
                {
                    result[column] = clone["BNA"];
                    break;
                }
            }

            if (clone["NUM"].ContainsText())
            {
                foreach (var column in "ADDRESS 1,ADDRESS 2,ADDRESS 3".Split(',')
                         .Where(column => result[column].IsEmpty()))
                {
                    var value = clone["NUM"];
                    if (clone["DST"].ContainsText())
                    {
                        value        = "{0} {1}".FormatWith(value, clone["DST"]);
                        clone["DST"] = string.Empty;
                    }
                    else if (clone["STM"].ContainsText())
                    {
                        value        = "{0} {1}".FormatWith(value, clone["STM"]);
                        clone["STM"] = string.Empty;
                    }

                    result[column] = value;
                    break;
                }
            }

            foreach (var source in "DST,STM,DDL,DLO,PTN".Split(',')
                     .Where(source => clone[source].ContainsText()))
            {
                const string keys = "ADDRESS 1,ADDRESS 2,ADDRESS 3,ADDRESS 4,ADDRESS 5,ADDRESS 6";
                foreach (var destination in keys.Split(',')
                         .Where(destination => result[destination].IsNullOrEmpty()))
                {
                    result[destination] = clone[source];
                    break;
                }
            }

            return(result);
        }
Ejemplo n.º 4
0
        public static MarketingAddress ToMarketingFormat(KeyStringDictionary entry)
        {
            if (null == entry)
            {
                throw new ArgumentNullException("entry");
            }

            var clone = entry.Clone<KeyStringDictionary>();
            var result = new MarketingAddress
                             {
                                 { "ADDRESS 1", string.Empty },
                                 { "ADDRESS 2", string.Empty },
                                 { "ADDRESS 3", string.Empty },
                                 { "ADDRESS 4", string.Empty },
                                 { "ADDRESS 5", string.Empty },
                                 { "ADDRESS 6", string.Empty },
                                 { "POSTCODE", clone["PCD"] },
                             };

            if (clone["SBN"].ContainsText())
            {
                result["ADDRESS 1"] = clone["SBN"];
            }

            if (clone["BNA"].ContainsText())
            {
                foreach (var column in "ADDRESS 1,ADDRESS 2".Split(',')
                                                            .Where(column => result[column].IsEmpty()))
                {
                    result[column] = clone["BNA"];
                    break;
                }
            }

            if (clone["NUM"].ContainsText())
            {
                foreach (var column in "ADDRESS 1,ADDRESS 2,ADDRESS 3".Split(',')
                                                                      .Where(column => result[column].IsEmpty()))
                {
                    var value = clone["NUM"];
                    if (clone["DST"].ContainsText())
                    {
                        value = "{0} {1}".FormatWith(value, clone["DST"]);
                        clone["DST"] = string.Empty;
                    }
                    else if (clone["STM"].ContainsText())
                    {
                        value = "{0} {1}".FormatWith(value, clone["STM"]);
                        clone["STM"] = string.Empty;
                    }

                    result[column] = value;
                    break;
                }
            }

            foreach (var source in "DST,STM,DDL,DLO,PTN".Split(',')
                                                        .Where(source => clone[source].ContainsText()))
            {
                const string keys = "ADDRESS 1,ADDRESS 2,ADDRESS 3,ADDRESS 4,ADDRESS 5,ADDRESS 6";
                foreach (var destination in keys.Split(',')
                                                .Where(destination => result[destination].IsNullOrEmpty()))
                {
                    result[destination] = clone[source];
                    break;
                }
            }

            return result;
        }