本文整理汇总了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);
}
}