コード例 #1
0
        public void ToXmlStringProvisioningTest()
        {
            var oldCulture = Thread.CurrentThread.CurrentCulture;
            try
            {

                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("de-DE");

                string projectsXml = @"
            <Projects>
                    <Project>
                        <ProjectID>999</ProjectID>
                        <ProjectName>Name of project</ProjectName>
                        <ServiceID>54</ServiceID>
                        <SourceLanguage>
                            <LanguageCode>en-gb</LanguageCode>
                        </SourceLanguage>
                        <TargetLanguages>
                                    <TargetLanguage>
                                        <LanguageCode>it-it</LanguageCode>
                                    </TargetLanguage>
                                    <TargetLanguage>
                                        <LanguageCode>fr-fr</LanguageCode>
                                    </TargetLanguage>
                        </TargetLanguages>
                        <Products>
                                <Product>
                                    <AssetID>999</AssetID>
                                    <SKUs>
                                        <SKU>
                                            <SKUNumber>123</SKUNumber>
                                        </SKU>
                                    </SKUs>
                                    <DueDate>2014-02-11T10:22:46Z</DueDate>
                                </Product>
                        </Products>
                        <ReferenceFiles>
                            <ReferenceFile>
                                <AssetID>12345</AssetID>
                                <FileName>my-file.txt</FileName>
                                <URL>https://ondemand.liondemand.com/api/files/12345</URL>
                                <TargetLanguages></TargetLanguages>
                            </ReferenceFile>
                            <ReferenceFile>
                                <AssetID>12346</AssetID>
                                <FileName>my-file.txt</FileName>
                                <URL>https://ondemand.liondemand.com/api/files/12346</URL>
                                <TargetLanguages></TargetLanguages>
                            </ReferenceFile>
                        </ReferenceFiles>
                    </Project>
            </Projects>
            ";

                XDocument document = XDocument.Parse(projectsXml);

                IEnumerable<Project> projects = Project.CreateEnumerable(document.Element("Projects"), new MockContentAPI());

                var quote = new Quote(quoteID: 795,
                                      creationDate: DateTime.Parse("2014-06-25T16:39:07Z"),
                                      totalTranslations: 2,
                                      translationCredit: 49984,
                                      totalCost: 0.00m,
                                      prepaidCredit: 118.99m,
                                      amountDue: 0.00m,
                                      currency: "EUR",
                                      projects: projects) { InternalBillingCode = "ABCD100001", PurchaseOrderNumber = "001-005-100" };

                string xml = @"
                <Quote>
                    <QuoteID>795</QuoteID>
                    <CreationDate>2014-06-25T16:39:07Z</CreationDate>
                    <TotalTranslations>2</TotalTranslations>
                    <TranslationCredit>49984</TranslationCredit>
                    <TotalCost>0.00</TotalCost>
                    <PrepaidCredit>118.99</PrepaidCredit>
                    <AmountDue>0.00</AmountDue>
                    <Currency>EUR</Currency>
                    <PurchaseOrderNumber>001-005-100</PurchaseOrderNumber>
                    <InternalBillingCode>ABCD100001</InternalBillingCode>
                    <Projects>
                            <Project>
                                <ProjectID>999</ProjectID>
                                <ProjectName>Name of project</ProjectName>
                                <ServiceID>54</ServiceID>
                                <SourceLanguage>
                                    <LanguageCode>en-gb</LanguageCode>
                                </SourceLanguage>
                                <TargetLanguages>
                                            <TargetLanguage>
                                                <LanguageCode>it-it</LanguageCode>
                                            </TargetLanguage>
                                            <TargetLanguage>
                                                <LanguageCode>fr-fr</LanguageCode>
                                            </TargetLanguage>
                                </TargetLanguages>
                                <Products>
                                        <Product>
                                            <AssetID>999</AssetID>
                                            <SKUs>
                                                <SKU>
                                                    <SKUNumber>123</SKUNumber>
                                                </SKU>
                                            </SKUs>
                                            <DueDate>2014-02-11T10:22:46Z</DueDate>
                                        </Product>
                                </Products>
                                <ReferenceFiles>
                                    <ReferenceFile>
                                        <AssetID>12345</AssetID>
                                        <FileName>my-file.txt</FileName>
                                        <URL>https://ondemand.liondemand.com/api/files/12345</URL>
                                        <TargetLanguages></TargetLanguages>
                                    </ReferenceFile>
                                    <ReferenceFile>
                                        <AssetID>12346</AssetID>
                                        <FileName>my-file.txt</FileName>
                                        <URL>https://ondemand.liondemand.com/api/files/12346</URL>
                                        <TargetLanguages></TargetLanguages>
                                    </ReferenceFile>
                                </ReferenceFiles>
                            </Project>
                    </Projects>
                </Quote>
            ";

                Assert.AreEqual(Regex.Replace(xml, @"\s", ""), Regex.Replace(quote.ToXmlString(), @"\s", ""));

            }
            finally
            {
                Thread.CurrentThread.CurrentCulture = oldCulture;
            }
        }
コード例 #2
0
        public void ToXmlStringPayAsYouGoTest()
        {
            string projectsXml = @"
            <Projects>
                    <Project>
                        <ProjectID>999</ProjectID>
                        <ProjectName>Name of project</ProjectName>
                        <ServiceID>54</ServiceID>
                        <SourceLanguage>
                            <LanguageCode>en-gb</LanguageCode>
                        </SourceLanguage>
                        <TargetLanguages>
                                    <TargetLanguage>
                                        <LanguageCode>it-it</LanguageCode>
                                    </TargetLanguage>
                                    <TargetLanguage>
                                        <LanguageCode>fr-fr</LanguageCode>
                                    </TargetLanguage>
                        </TargetLanguages>
                        <Products>
                                <Product>
                                    <AssetID>999</AssetID>
                                    <SKUs>
                                        <SKU>
                                            <SKUNumber>123</SKUNumber>
                                        </SKU>
                                    </SKUs>
                                    <DueDate>2014-02-11T10:22:46Z</DueDate>
                                </Product>
                        </Products>
                        <ReferenceFiles>
                            <ReferenceFile>
                                <AssetID>12345</AssetID>
                                <FileName>my-file.txt</FileName>
                                <URL>https://ondemand.liondemand.com/api/files/12345</URL>
                                <TargetLanguages></TargetLanguages>
                            </ReferenceFile>
                            <ReferenceFile>
                                <AssetID>12346</AssetID>
                                <FileName>my-file.txt</FileName>
                                <URL>https://ondemand.liondemand.com/api/files/12346</URL>
                                <TargetLanguages></TargetLanguages>
                            </ReferenceFile>
                        </ReferenceFiles>
                    </Project>
            </Projects>
            ";

            XDocument document = XDocument.Parse(projectsXml);

            IEnumerable<Project> projects = Project.CreateEnumerable(document.Element("Projects"), new MockContentAPI());

            var quote = new Quote(quoteID: 795,
                                  creationDate: DateTime.Parse("2014-06-25T16:39:07Z"),
                                  totalTranslations: 2,
                                  translationCredit: 49984,
                                  totalCost: 0.00m,
                                  prepaidCredit: 118.99m,
                                  amountDue: 0.00m,
                                  currency: "EUR",
                                  projects: projects);

            string xml = @"
                <Quote>
                    <QuoteID>795</QuoteID>
                    <CreationDate>2014-06-25T16:39:07Z</CreationDate>
                    <TotalTranslations>2</TotalTranslations>
                    <TranslationCredit>49984</TranslationCredit>
                    <TotalCost>0.00</TotalCost>
                    <PrepaidCredit>118.99</PrepaidCredit>
                    <AmountDue>0.00</AmountDue>
                    <Currency>EUR</Currency>
                    <Projects>
                            <Project>
                                <ProjectID>999</ProjectID>
                                <ProjectName>Name of project</ProjectName>
                                <ServiceID>54</ServiceID>
                                <SourceLanguage>
                                    <LanguageCode>en-gb</LanguageCode>
                                </SourceLanguage>
                                <TargetLanguages>
                                            <TargetLanguage>
                                                <LanguageCode>it-it</LanguageCode>
                                            </TargetLanguage>
                                            <TargetLanguage>
                                                <LanguageCode>fr-fr</LanguageCode>
                                            </TargetLanguage>
                                </TargetLanguages>
                                <Products>
                                        <Product>
                                            <AssetID>999</AssetID>
                                            <SKUs>
                                                <SKU>
                                                    <SKUNumber>123</SKUNumber>
                                                </SKU>
                                            </SKUs>
                                            <DueDate>2014-02-11T10:22:46Z</DueDate>
                                        </Product>
                                </Products>
                                <ReferenceFiles>
                                    <ReferenceFile>
                                        <AssetID>12345</AssetID>
                                        <FileName>my-file.txt</FileName>
                                        <URL>https://ondemand.liondemand.com/api/files/12345</URL>
                                <TargetLanguages></TargetLanguages>
                                    </ReferenceFile>
                                    <ReferenceFile>
                                        <AssetID>12346</AssetID>
                                        <FileName>my-file.txt</FileName>
                                        <URL>https://ondemand.liondemand.com/api/files/12346</URL>
                                        <TargetLanguages></TargetLanguages>
                                    </ReferenceFile>
                                </ReferenceFiles>
                            </Project>
                    </Projects>
                </Quote>
            ";

            Assert.AreEqual(Regex.Replace(xml, @"\s", ""), Regex.Replace(quote.ToXmlString(), @"\s", ""));
        }