Пример #1
0
        public IScheduleRecord ParseRecord(string recordString)
        {
            if (string.IsNullOrWhiteSpace(recordString))
            {
                throw new ArgumentNullException(nameof(recordString));
            }

            var record = new TiplocRecord
            {
                RecordIdentity         = ScheduleRecordType.TA,
                TiplocCode             = recordString.Substring(2, 7).Trim(),
                CapitalsIdentification = recordString.Substring(9, 2).Trim(),
                Nalco            = recordString.Substring(11, 6).Trim(),
                Nlc              = recordString.Substring(17, 1).Trim(),
                TpsDescription   = recordString.Substring(18, 26).Trim().LocationCasing(),
                Stanox           = recordString.Substring(44, 5).Trim(),
                PoMcbCode        = recordString.Substring(49, 4).Trim(),
                CrsCode          = recordString.Substring(53, 3).Trim(),
                CapriDescription = recordString.Substring(56, 16).Trim().LocationCasing()
            };

            var newTiploc = recordString.Substring(72, 7).Trim();

            if (newTiploc == string.Empty)
            {
                return(record);
            }

            record.OldTiploc  = record.TiplocCode;
            record.TiplocCode = newTiploc;

            return(record);
        }
Пример #2
0
        public void returns_expected_result()
        {
            var recordParser   = BuildParser();
            var recordToParse  = "TD1234567                                                                       ";
            var expectedResult = new TiplocRecord
            {
                RecordIdentity = ScheduleRecordType.TD,
                TiplocCode     = "1234567"
            };

            var result = recordParser.ParseRecord(recordToParse);

            Assert.AreEqual(expectedResult, result);
        }
        public void returns_expected_result()
        {
            var recordParser = BuildParser();
            var recordToParse = "TD1234567                                                                       ";
            var expectedResult = new TiplocRecord
            {
                RecordIdentity = ScheduleRecordType.TD,
                TiplocCode = "1234567"
            };

            var result = recordParser.ParseRecord(recordToParse);

            Assert.AreEqual(expectedResult, result);
        }
Пример #4
0
 protected bool Equals(TiplocRecord other)
 {
     return(Id == other.Id &&
            RecordIdentity == other.RecordIdentity &&
            string.Equals(TiplocCode, other.TiplocCode) &&
            string.Equals(CapitalsIdentification, other.CapitalsIdentification) &&
            string.Equals(Nalco, other.Nalco) &&
            string.Equals(Nlc, other.Nlc) &&
            string.Equals(TpsDescription, other.TpsDescription) &&
            string.Equals(Stanox, other.Stanox) &&
            string.Equals(PoMcbCode, other.PoMcbCode) &&
            string.Equals(CrsCode, other.CrsCode) &&
            string.Equals(CapriDescription, other.CapriDescription) &&
            string.Equals(OldTiploc, other.OldTiploc));
 }
        public IScheduleRecord ParseRecord(string recordString)
        {
            if (string.IsNullOrWhiteSpace(recordString))
            {
                throw new ArgumentNullException(nameof(recordString));
            }

            var record = new TiplocRecord
            {
                RecordIdentity = ScheduleRecordType.TD,
                TiplocCode     = recordString.Substring(2, 7).Trim()
            };

            return(record);
        }
        public void returns_expected_result()
        {
            var recordParser   = BuildParser();
            var recordToParse  = "TIPURLSGB00537901JPURLEY DOWN SIDING GBRF   87807   0                           ";
            var expectedResult = new TiplocRecord
            {
                RecordIdentity         = ScheduleRecordType.TI,
                TiplocCode             = "PURLSGB",
                CapitalsIdentification = "00",
                Nalco            = "537901",
                Nlc              = "J",
                TpsDescription   = "PURLEY DOWN SIDING GBRF",
                Stanox           = "87807",
                PoMcbCode        = "0",
                CrsCode          = string.Empty,
                CapriDescription = string.Empty
            };

            var result = recordParser.ParseRecord(recordToParse) as TiplocRecord;

            Assert.AreEqual(expectedResult, result);
        }
        public void returns_expected_result()
        {
            var recordParser = BuildParser();
            var recordToParse = "TIPURLSGB00537901JPURLEY DOWN SIDING GBRF   87807   0                           ";
            var expectedResult = new TiplocRecord
            {
                RecordIdentity = ScheduleRecordType.TI,
                TiplocCode = "PURLSGB",
                CapitalsIdentification = "00",
                Nalco = "537901",
                Nlc = "J",
                TpsDescription = "PURLEY DOWN SIDING GBRF",
                Stanox = "87807",
                PoMcbCode = "0",
                CrsCode = string.Empty,
                CapriDescription = string.Empty
            };

            var result = recordParser.ParseRecord(recordToParse) as TiplocRecord;

            Assert.AreEqual(expectedResult, result);
        }
        public void returns_expected_result()
        {
            var recordParser   = BuildParser();
            var recordToParse  = "TAEBOUCS 08544815BEASTBOURNE C.S.           88253   0XEB                0111193 ";
            var expectedResult = new TiplocRecord
            {
                RecordIdentity         = ScheduleRecordType.TA,
                TiplocCode             = "0111193",
                CapitalsIdentification = "08",
                Nalco            = "544815",
                Nlc              = "B",
                TpsDescription   = "EASTBOURNE C.S.",
                Stanox           = "88253",
                PoMcbCode        = "0",
                CrsCode          = "XEB",
                CapriDescription = string.Empty,
                OldTiploc        = "EBOUCS"
            };

            var result = recordParser.ParseRecord(recordToParse) as TiplocRecord;

            Assert.AreEqual(expectedResult, result);
        }
        public void returns_expected_result()
        {
            var recordParser = BuildParser();
            var recordToParse = "TAEBOUCS 08544815BEASTBOURNE C.S.           88253   0XEB                0111193 ";
            var expectedResult = new TiplocRecord
            {
                RecordIdentity = ScheduleRecordType.TA,
                TiplocCode = "0111193",
                CapitalsIdentification = "08",
                Nalco = "544815",
                Nlc = "B",
                TpsDescription = "EASTBOURNE C.S.",
                Stanox = "88253",
                PoMcbCode = "0",
                CrsCode = "XEB",
                CapriDescription = string.Empty,
                OldTiploc = "EBOUCS"
            };

            var result = recordParser.ParseRecord(recordToParse) as TiplocRecord;

            Assert.AreEqual(expectedResult, result);
        }