public void ResumeMapperUnitTests_ToWorkModel() { // Arrange const string titleValue = "a"; const string linkValue = "c"; const string subtitleValue = "d"; const string imageValue = "e"; const string periodValue = "f"; const string contentValue = "g"; XElement coverElement = new XElement( "cover", new XElement("title", titleValue), new XElement("link", linkValue), new XElement("subtitle", subtitleValue), new XElement("image", imageValue), new XElement("period", periodValue) ); XElement workElement = new XElement("work", coverElement, new XElement("content", contentValue)); XDocument document = new XDocument(workElement); IWorkModelDao dao = new WorkModelXmlDao(document); // Act WorkModel model = ResumeMapper.ToWorkModel(dao); // Assert Assert.IsNotNull(model); Assert.AreEqual(titleValue, model.Title); Assert.AreEqual(linkValue, model.Link); Assert.AreEqual(subtitleValue, model.Subtitle); Assert.AreEqual(imageValue, model.Image); Assert.AreEqual(periodValue, model.Period); Assert.AreEqual(contentValue, model.Content); }
public WorkModel GetWorkModel(string workModelName) { if (_knownWorks.ContainsKey(workModelName)) { string xmlFileName = _knownWorks[workModelName]; string xmlFilePath = $"{_hostingEnvironment.WebRootPath}{xmlFileName}"; XDocument xmlFile = XDocument.Load(xmlFilePath); IWorkModelDao dao = new WorkModelXmlDao(xmlFile); return(ResumeMapper.ToWorkModel(dao)); } else { throw new WorkNotKnownException($"No known work named {workModelName}"); } }