public void FinishedGoodsExportFormFileNameTest()
        {
            string         m_Pattern     = @"\bP\w+\st\w+\s+(\d{7})";
            int            number        = new Random().Next(1, 9999999);
            string         _pattern      = "Proces technologiczny {0:D7}"; // Settings.FinishedGoodsExportFormFileName( number );
            string         _documentName = String.Format(_pattern, number);
            Nullable <int> actual        = XMLResources.GetRequiredDocumentFinishedGoodExportConsignmentNumber(_documentName, m_Pattern);

            Assert.AreEqual(number, actual);
            actual = XMLResources.GetRequiredDocumentFinishedGoodExportConsignmentNumber("Proces xechnologiczny 1234567", m_Pattern);
            Assert.IsFalse(actual.HasValue);
            actual = XMLResources.GetRequiredDocumentFinishedGoodExportConsignmentNumber("Proces Technologiczny 123456", m_Pattern);
            Assert.IsFalse(actual.HasValue);
        }
        public void CWWyprowadzenieFileNameTest()
        {
            string         m_Pattern     = @"\bC\w+\sW\w+\s+(\d{7})";
            int            number        = new Random().Next(1, 9999999);
            string         _pattern      = "CW Wyprowadzenie {0:D7}"; // Settings.FinishedGoodsExportFormFileName( number );
            string         _documentName = String.Format(_pattern, number);
            Nullable <int> actual        = XMLResources.GetRequiredDocumentFinishedGoodExportConsignmentNumber(_documentName, m_Pattern);

            Assert.AreEqual(number, actual);
            _pattern      = "CW    Wyprowadzenie     {0:D7}"; // Settings.FinishedGoodsExportFormFileName( number );
            _documentName = String.Format(_pattern, number);
            actual        = XMLResources.GetRequiredDocumentFinishedGoodExportConsignmentNumber(_documentName, m_Pattern);
            Assert.AreEqual(number, actual);
            actual = XMLResources.GetRequiredDocumentFinishedGoodExportConsignmentNumber("CW xyprowadzenie 1234567", m_Pattern);
            Assert.IsFalse(actual.HasValue);
            actual = XMLResources.GetRequiredDocumentFinishedGoodExportConsignmentNumber("CW xyprowadzenie 123456", m_Pattern);
            Assert.IsFalse(actual.HasValue);
            actual = XMLResources.GetRequiredDocumentFinishedGoodExportConsignmentNumber("CW xyprowadzenie1234567", m_Pattern);
            Assert.IsFalse(actual.HasValue);
        }
        private static List <Clearence> GetClearanceIds(Entities entities, SADGood good, string pattern)
        {
            List <Clearence> _ret = new List <Clearence>();

            foreach (SADRequiredDocuments _rdx in good.SADRequiredDocuments(entities))
            {
                if (_rdx.Code != XMLResources.RequiredDocumentConsignmentCode)
                {
                    continue;
                }
                int?_cleranceInt = XMLResources.GetRequiredDocumentFinishedGoodExportConsignmentNumber(_rdx.Number, pattern);
                if (!_cleranceInt.HasValue)
                {
                    continue;
                }
                if (_cleranceInt.HasValue)
                {
                    Clearence _clearance = Element.GetAtIndex <Clearence>(entities.Clearence, _cleranceInt.Value);
                    _ret.Add(_clearance);
                }
                else
                {
                    string _template = "Cannot find clearance for the required document code={0} for customs document = {1}/ref={2}";
                    throw new InputDataValidationException(
                              String.Format(_template, _rdx.Number, good.SADDocumentIndex.DocumentNumber, good.SADDocumentIndex.ReferenceNumber),
                              "SAD Required Documents",
                              "clear through customs fatal error", true);
                }
            }// foreach
            if (_ret.Count == 0)
            {
                string _template = "Cannot find required document code={0} for customs document = {1}/ref={2}";
                throw new InputDataValidationException(
                          String.Format(_template, XMLResources.RequiredDocumentConsignmentCode, good.SADDocumentIndex.DocumentNumber, good.SADDocumentIndex.ReferenceNumber),
                          "SAD Required Documents",
                          "clear through customs fatal error", true);
            }
            return(_ret);
        }