当前位置: 首页>>代码示例>>C#>>正文


C# IServices.GetAnswers方法代码示例

本文整理汇总了C#中IServices.GetAnswers方法的典型用法代码示例。如果您正苦于以下问题:C# IServices.GetAnswers方法的具体用法?C# IServices.GetAnswers怎么用?C# IServices.GetAnswers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IServices的用法示例。


在下文中一共展示了IServices.GetAnswers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAnswers

        private void GetAnswers(IServices svc, string logRef)
        {
            List<TextReader> answersList = new List<TextReader>();
            string xml;

            // Ensure that invalid parameters are throwing an appropriate exception.
            try
            {
                xml = svc.GetAnswers(null, null);
                Assert.Fail(); // Should have failed instead of reaching here.
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsTrue(ex.Message.IndexOf("answers") > 0);
            }

            // Perform all of these tests a number of times using different formats of the answers each time.
            // The .txt files are base64 encoded versions of the matching .xml files.
            for (int i = 0; i < 4; i++)
            {
                string answerFile1 = "Freddy.txt"; ;
                string answerFile2 = "Frederick.txt";
                switch (i)
                {
                    case 0:
                        answerFile1 = "Freddy.txt";
                        answerFile2 = "Frederick.txt";
                        break;
                    case 1:
                        answerFile1 = "Freddy.txt";
                        answerFile2 = "Frederick.xml";
                        break;
                    case 2:
                        answerFile1 = "Freddy.xml";
                        answerFile2 = "Frederick.txt";
                        break;
                    case 3:
                        answerFile1 = "Freddy.xml";
                        answerFile2 = "Frederick.xml";
                        break;
                }

                // Get the Freddy answer file.
                answersList.Clear();
                answersList.Add(Util.GetTestFile(answerFile1));
                xml = svc.GetAnswers(answersList.ToArray(), logRef);
                Assert.IsTrue(xml.IndexOf("running the company") > 0);
                Assert.IsTrue(xml.IndexOf("Freddy") > 0);

                // Get the Frederick answer file.
                answersList.Clear();
                answersList.Add(Util.GetTestFile(answerFile2));
                xml = svc.GetAnswers(answersList.ToArray(), logRef);
                Assert.IsTrue(xml.IndexOf("Here is your new car") > 0);
                Assert.IsTrue(xml.IndexOf("Frederick") > 0);

                // Get the combined answer file with Frederick answers overlayed on top of Freddy answers.
                answersList.Clear();
                answersList.Add(Util.GetTestFile(answerFile1));
                answersList.Add(Util.GetTestFile(answerFile2));
                xml = svc.GetAnswers(answersList.ToArray(), logRef);
                Assert.IsTrue(xml.IndexOf("running the company") > 0);
                Assert.IsTrue(xml.IndexOf("Here is your new car") > 0);
                Assert.IsTrue(xml.IndexOf("Frederick") > 0);
                Assert.IsTrue(xml.IndexOf("Freddy") < 0);

                // Get the combined answer file with Freddy answers overlayed on top of Frederick answers.
                answersList.Clear();
                answersList.Add(Util.GetTestFile(answerFile2));
                answersList.Add(Util.GetTestFile(answerFile1));
                xml = svc.GetAnswers(answersList.ToArray(), logRef);
                Assert.IsTrue(xml.IndexOf("running the company") > 0);
                Assert.IsTrue(xml.IndexOf("Here is your new car") > 0);
                Assert.IsTrue(xml.IndexOf("Freddy") > 0);
                Assert.IsTrue(xml.IndexOf("Frederick") < 0);
            }
        }
开发者ID:MMetodiew,项目名称:hotdocs-open-sdk,代码行数:77,代码来源:ServicesTest.cs


注:本文中的IServices.GetAnswers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。