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


C# IServices.GetInterview方法代码示例

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


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

示例1: GetInterview

        private void GetInterview(IServices svc, string logRef)
        {
            // Set up the InterviewOptions for the test.
            Template tmp = Util.OpenTemplate("d1f7cade-cb74-4457-a9a0-27d94f5c2d5b");
            string postInterviewUrl = "PostInterview.aspx";
            string styleSheetUrl = "HDServerFiles/Stylesheets";
            string runtimeUrl = "HDServerFiles/js";
            string interviewDefUrl = "GetInterviewFile.ashx";
            //string interviewImgUrl = "GetInterviewFile.ashx";
            InterviewSettings settings = new InterviewSettings(postInterviewUrl, runtimeUrl, styleSheetUrl, interviewDefUrl);

            // Set up the Marked Variables for the test.
            string[] markedVars = null; // new string[] { };

            InterviewResult result;

            // Make sure that the parameters are being validated correctly.
            try
            {
                svc.GetInterview(null, null, null, null, null);
                Assert.Fail(); // If we get here then the exceptions were not fired as they should have been with all null parameters.
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsTrue(ex.Message.IndexOf(": template") > 0);
            }
            catch (Exception)
            {
                Assert.Fail(); // Not expecting a generic exception.
            }

            result = svc.GetInterview(tmp, null, settings, markedVars, logRef);
            Assert.AreNotEqual(result.HtmlFragment, "");
            Assert.IsTrue(result.HtmlFragment.Contains(settings.PostInterviewUrl));
            Assert.IsTrue(result.HtmlFragment.Contains(runtimeUrl));
            Assert.IsTrue(result.HtmlFragment.Contains(styleSheetUrl));
            Assert.IsTrue(result.HtmlFragment.Contains(interviewDefUrl));
            //Assert.IsTrue(result.HtmlFragment.Contains(interviewImgUrl));
            Assert.IsTrue(result.HtmlFragment.Contains("hdMainDiv"));
            Assert.IsFalse(result.HtmlFragment.Contains("Employee Name\": { t: \"TX\", m:true")); // Employee Name should not be "marked"

            // Now get another interview, but this time specify a url for doc preview and save answers.
            settings.DocumentPreviewUrl = "DocPreview.aspx";
            settings.SaveAnswersUrl = "SaveAnswers.aspx";
            settings.Format = InterviewFormat.JavaScript; // explicitly set format to JS.
            result = svc.GetInterview(tmp, null, settings, markedVars, logRef);
            Assert.IsTrue(result.HtmlFragment.Contains(settings.DocumentPreviewUrl));
            Assert.IsTrue(result.HtmlFragment.Contains(settings.SaveAnswersUrl));
            Assert.IsTrue(result.HtmlFragment.Contains("HDJavaScriptInterview"));

            // Now get another interview, but this time do the following:
            // 1. Disable the doc preview and save answers urls.
            // 2. Do not include the hdMainDiv.
            // 3. "Mark" the Employee Name variable.
            // 4. Set the interview format to Silverlight.
            settings.DisableDocumentPreview = true;
            settings.DisableSaveAnswers = true;
            settings.AddHdMainDiv = Tristate.False;
            settings.Format = InterviewFormat.Silverlight;
            markedVars = new string[] { "Employee Name" };
            result = svc.GetInterview(tmp, null, settings, markedVars, logRef);
            Assert.IsFalse(result.HtmlFragment.Contains(settings.DocumentPreviewUrl));
            Assert.IsFalse(result.HtmlFragment.Contains(settings.SaveAnswersUrl), "No Save Ans Url because it is disabled");
            Assert.IsTrue(result.HtmlFragment.Contains("Employee Name\": { t: \"TX\", m:true")); // This interview does "mark" Employee Name.
            Assert.IsTrue(result.HtmlFragment.Contains("HDSilverlightInterview"));

            // Only HotDocs Cloud Services honors the AddHdMainDiv property of InterviewSettings, so only bother checking it if we are running a test against cloud services.
            if (svc is HotDocs.Sdk.Server.Cloud.Services)
                Assert.IsFalse(result.HtmlFragment.Contains("hdMainDiv"));

            // Now try once more with a null value for settings to allow the default settings to be used.
            // Also, in this test we are using an actual answer file so that we can test using answers.
            TextReader answers = Util.GetTestFile("Freddy.xml");
            result = svc.GetInterview(tmp, answers, null, markedVars, logRef);
            Assert.IsTrue(result.HtmlFragment.Contains("Freddy"));
        }
开发者ID:MMetodiew,项目名称:hotdocs-open-sdk,代码行数:76,代码来源:ServicesTest.cs


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