public void TypicalEmbedInMyXmlDocument() { var system = new OlacSystem(); var work = new Work(); work.Licenses.Add(License.CreativeCommons_Attribution_ShareAlike); work.Contributions.Add(new Contribution("Charlie Brown", system.GetRoleByCodeOrThrow("author"))); work.Contributions.Add(new Contribution("Linus", system.GetRoleByCodeOrThrow("editor"))); string metaData = system.GetXmlForWork(work); //Embed that data in our own file using (var f = new TempFile(@"<doc> <metadata>" + metaData + @"</metadata> <ourDocumentContents>blah blah<ourDocumentContents/></doc>" )) { //Then when it comes time to read the file, we can extract out the work again var dom = new XmlDocument(); dom.Load(f.Path); var node = dom.SelectSingleNode("//metadata"); var work2 = new Work(); system.LoadWorkFromXml(work2, node.InnerXml); Assert.AreEqual(2, work2.Contributions.Count()); } }
public void SetContributors_SetTwice_ThrowsInvalidOperationException() { var contributors = new ContributionCollection(); OlacSystem olacSystem = new OlacSystem(); Role role = olacSystem.GetRoleByCodeOrThrow("author"); var contrib = new Contribution("Erkel", role); contributors.Add(contrib); _helper.SetContributors(contributors); Assert.Throws <InvalidOperationException>(() => _helper.SetContributors(contributors)); }
public void TestSetup() { var system = new OlacSystem(); _model = new ContributorsListControlViewModel(null, null); _contributions = new ContributionCollection(new[] { new Contribution("Leroy", system.GetRoles().ElementAt(0)), new Contribution("Jed", system.GetRoles().ElementAt(1)), new Contribution("Art", system.GetRoles().ElementAt(2)) }); _model.SetContributionList(_contributions); }
public void SetContributors_TwoContributors_IncludedInMetsData() { var contributors = new ContributionCollection(); OlacSystem olacSystem = new OlacSystem(); contributors.Add(new Contribution("Erkel", olacSystem.GetRoleByCodeOrThrow("author"))); contributors.Add(new Contribution("Sungfu", olacSystem.GetRoleByCodeOrThrow("recorder"))); _helper.SetContributors(contributors); var data = _helper.GetMetadata(); Assert.AreEqual("{\"dc.title\":\"Test Title\",\"" + RampArchivingDlgViewModel.kContributor + "\":{\"0\":{\" \":\"Erkel\",\"role\":\"author\"},\"1\":{\" \":\"Sungfu\",\"role\":\"recorder\"}}}", data); }
public void TestSetup() { _system = new OlacSystem(); }