private void TestTemplate(Template template, TemplateInfo tInfo)
        {
            Assert.IsFalse(template.HasInterview);
            Assert.IsTrue(template.GeneratesDocument == (tInfo.TmpType != TemplateType.InterviewOnly));
            Assert.AreEqual(template.NativeDocumentType, tInfo.DocType);
            Assert.AreEqual(template.TemplateType, tInfo.TmpType);

            string locator = template.CreateLocator();
            Template template2 = Template.Locate(locator);

            Assert.AreEqual(template.FileName, template2.FileName);
            Assert.AreEqual(template.Key, template2.Key);
            Assert.AreEqual(template.Switches, template2.Switches);
            Assert.AreEqual(template.Title, template2.Title);
            Assert.AreEqual(template.GeneratesDocument, template2.GeneratesDocument);
            Assert.AreEqual(template.HasInterview, template2.HasInterview);
            Assert.AreEqual(template.NativeDocumentType, template2.NativeDocumentType);
            Assert.AreEqual(template.TemplateType, template2.TemplateType);

            template.UpdateFileName();
            Assert.AreEqual(template.FileName, template2.FileName);

            Assert.AreEqual(".hfd", HotDocs.Sdk.Template.GetDocExtension(DocumentType.HFD, null));
            Assert.AreEqual(".hpd", HotDocs.Sdk.Template.GetDocExtension(DocumentType.HPD, null));
            Assert.AreEqual(".htm", HotDocs.Sdk.Template.GetDocExtension(DocumentType.HTML, null));
            Assert.AreEqual(".htm", HotDocs.Sdk.Template.GetDocExtension(DocumentType.HTMLwDataURIs, null));
            Assert.AreEqual(".htm", HotDocs.Sdk.Template.GetDocExtension(DocumentType.MHTML, null));
            Assert.AreEqual(".pdf", HotDocs.Sdk.Template.GetDocExtension(DocumentType.PDF, null));
            Assert.AreEqual(".txt", HotDocs.Sdk.Template.GetDocExtension(DocumentType.PlainText, null));
            Assert.AreEqual(".doc", HotDocs.Sdk.Template.GetDocExtension(DocumentType.WordDOC, null));
            Assert.AreEqual(".docx", HotDocs.Sdk.Template.GetDocExtension(DocumentType.WordDOCX, null));
            Assert.AreEqual(".wpd", HotDocs.Sdk.Template.GetDocExtension(DocumentType.WordPerfect, null));
            Assert.AreEqual(".rtf", HotDocs.Sdk.Template.GetDocExtension(DocumentType.WordRTF, null));
            //Assert.AreEqual(".xml", HotDocs.Sdk.Template.GetDocExtension(DocumentType.XML, null)); // TODO: Should we be testing XML?

            // Unknown doc type.
            try
            {
                Assert.AreEqual(".unk", HotDocs.Sdk.Template.GetDocExtension(DocumentType.Unknown, null));
                Assert.Fail(); // Should have thrown exception.
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.Message.Contains("Unsupported document type."));
            }

            // Native doc type.
            try
            {
                string extension = HotDocs.Sdk.Template.GetDocExtension(DocumentType.Native, null);
                Assert.Fail(); // We should have had an exception.
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsTrue(ex.Message.Contains("template")); // templae cannot be null if the type is Native.
            }

            // Native doc type.
            if (tInfo.DocType != DocumentType.Unknown)
            {
                Assert.AreEqual(tInfo.DocExtension, template.GetDocExtension());
                Assert.AreEqual(tInfo.DocExtension, HotDocs.Sdk.Template.GetDocExtension(DocumentType.Native, template));
            }

            // Set the template title.
            template.Title = "This has been done.";
            Assert.AreEqual("This has been done.", template.Title);
        }
        private void TestTemplate(Template template, TemplateInfo tInfo)
        {
            Assert.IsFalse(template.HasInterview);
            Assert.IsTrue(template.GeneratesDocument == (tInfo.TmpType != TemplateType.InterviewOnly));
            Assert.AreEqual(template.NativeDocumentType, tInfo.DocType);
            Assert.AreEqual(template.TemplateType, tInfo.TmpType);

            string   locator   = template.CreateLocator();
            Template template2 = Template.Locate(locator);

            Assert.AreEqual(template.FileName, template2.FileName);
            Assert.AreEqual(template.Key, template2.Key);
            Assert.AreEqual(template.Switches, template2.Switches);
            Assert.AreEqual(template.Title, template2.Title);
            Assert.AreEqual(template.GeneratesDocument, template2.GeneratesDocument);
            Assert.AreEqual(template.HasInterview, template2.HasInterview);
            Assert.AreEqual(template.NativeDocumentType, template2.NativeDocumentType);
            Assert.AreEqual(template.TemplateType, template2.TemplateType);

            template.UpdateFileName();
            Assert.AreEqual(template.FileName, template2.FileName);

            Assert.AreEqual(".hfd", HotDocs.Sdk.Template.GetDocExtension(DocumentType.HFD, null));
            Assert.AreEqual(".hpd", HotDocs.Sdk.Template.GetDocExtension(DocumentType.HPD, null));
            Assert.AreEqual(".htm", HotDocs.Sdk.Template.GetDocExtension(DocumentType.HTML, null));
            Assert.AreEqual(".htm", HotDocs.Sdk.Template.GetDocExtension(DocumentType.HTMLwDataURIs, null));
            Assert.AreEqual(".htm", HotDocs.Sdk.Template.GetDocExtension(DocumentType.MHTML, null));
            Assert.AreEqual(".pdf", HotDocs.Sdk.Template.GetDocExtension(DocumentType.PDF, null));
            Assert.AreEqual(".txt", HotDocs.Sdk.Template.GetDocExtension(DocumentType.PlainText, null));
            Assert.AreEqual(".doc", HotDocs.Sdk.Template.GetDocExtension(DocumentType.WordDOC, null));
            Assert.AreEqual(".docx", HotDocs.Sdk.Template.GetDocExtension(DocumentType.WordDOCX, null));
            Assert.AreEqual(".wpd", HotDocs.Sdk.Template.GetDocExtension(DocumentType.WordPerfect, null));
            Assert.AreEqual(".rtf", HotDocs.Sdk.Template.GetDocExtension(DocumentType.WordRTF, null));
            //Assert.AreEqual(".xml", HotDocs.Sdk.Template.GetDocExtension(DocumentType.XML, null)); // TODO: Should we be testing XML?

            // Unknown doc type.
            try
            {
                Assert.AreEqual(".unk", HotDocs.Sdk.Template.GetDocExtension(DocumentType.Unknown, null));
                Assert.Fail();                 // Should have thrown exception.
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.Message.Contains("Unsupported document type."));
            }

            // Native doc type.
            try
            {
                string extension = HotDocs.Sdk.Template.GetDocExtension(DocumentType.Native, null);
                Assert.Fail();                 // We should have had an exception.
            }
            catch (ArgumentNullException ex)
            {
                Assert.IsTrue(ex.Message.Contains("template"));                 // templae cannot be null if the type is Native.
            }

            // Native doc type.
            if (tInfo.DocType != DocumentType.Unknown)
            {
                Assert.AreEqual(tInfo.DocExtension, template.GetDocExtension());
                Assert.AreEqual(tInfo.DocExtension, HotDocs.Sdk.Template.GetDocExtension(DocumentType.Native, template));
            }


            // Set the template title.
            template.Title = "This has been done.";
            Assert.AreEqual("This has been done.", template.Title);
        }