public void TimetableDocumentTemplateModelExtensionsClass_ToDocumentTemplateMethod_ThrowsArgumentNullException_IfParameterIsNull()
        {
            TimetableDocumentTemplateModel testObject = null;

            _ = testObject.ToDocumentTemplate();

            Assert.Fail();
        }
        public void TimetableDocumentTemplateModelExtensionsClass_ToDocumentTemplateMethod_ThrowsArgumentNullExceptionWithCorrectParamNameProperty_IfParameterIsNull()
        {
            TimetableDocumentTemplateModel testObject = null;

            try
            {
                _ = testObject.ToDocumentTemplate();
                Assert.Fail();
            }
            catch (ArgumentNullException ex)
            {
                Assert.AreEqual("model", ex.ParamName);
            }
        }
        internal static DocumentTemplate LoadXmlDocumentTemplate(Stream str)
        {
            try
            {
                using (XmlReader reader = XmlReader.Create(str))
                {
                    if (reader == null)
                    {
                        throw new TimetableLoaderException(Resources.Error_CouldNotCreateXmlReader);
                    }
                    reader.MoveToContent();
                    if (reader.Name != "TimetableDocumentTemplate")
                    {
                        throw new TimetableLoaderException(Resources.Error_XmlDoesNotContainTimetableDocumentTemplate);
                    }
                    if (!int.TryParse(reader.GetAttribute("version"), out int version))
                    {
                        throw new TimetableLoaderException(Resources.Error_XmlTimetableDocumentTemplateDoesNotSpecifyVersion);
                    }
                    if (version > Versions.CurrentDocumentTemplate)
                    {
                        throw new TimetableLoaderException(string.Format(CultureInfo.CurrentCulture, Resources.Error_XmlTimetableDocumentTemplateUnsupportedVersion, version));
                    }

                    // Version-detection code to go here.
                    XmlSerializer deserializer = new XmlSerializer(typeof(TimetableDocumentTemplateModel));
                    TimetableDocumentTemplateModel templateModel = (TimetableDocumentTemplateModel)deserializer.Deserialize(reader);
                    return(templateModel.ToDocumentTemplate());
                }
            }
            catch (TimetableLoaderException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new TimetableLoaderException(Resources.Error_GenericLoaderError, ex);
            }
        }