BloomTests.Book.BookCopyrightAndLicenseTests.CheckUpdateDomFromDataDiv C# (CSharp) Method

CheckUpdateDomFromDataDiv() private method

Start out with an html with a bloomDataDiv describe by the parameters, then run it through the derivation of elements, then check to see that we got the expected result
private CheckUpdateDomFromDataDiv ( string key, string dataDivValue, string lang1 = "en", string lang2 = "", string lang3 = "", string description = null, string customXPath = null ) : void
key string the data key. E.g. 'licenseDescription'
dataDivValue string if null, then the element should not be present at all in the bloomDataDiv of the incoming html
lang1 string
lang2 string
lang3 string
description string
customXPath string
return void
		private void CheckUpdateDomFromDataDiv(string key, string dataDivValue,  string lang1="en", string lang2="", string lang3="", string description=null, string customXPath=null)
		{
			if (description == null)
				description = string.Format("{0} should be '{1}'", key, dataDivValue);

			_collectionSettings.Language1Iso639Code = lang1;
			_collectionSettings.Language2Iso639Code = lang2;
			_collectionSettings.Language3Iso639Code = lang3;

			var existingLicenseBlockOnPage = @"<div id='test'>
						<div data-derived = 'copyright' lang='en'>Some Copyright</div>
						<img src='license.png' alt='blah blah' data-derived='licenseImage'/>
						<div data-derived = 'licenseUrl' lang='en'>Boilerplate.com</div>
						<div data-derived='licenseDescription' lang='en'>BoilerPlateDescription</div>
						<div data-derived='licenseNotes' lang='en'>BoilerPlateNotes</div>
					</div>";

			string html= "<html><body><div id='bloomDataDiv'>";
			if (dataDivValue != null) //we want this even if it is empty, just not null
			{
					html += string.Format("<{0} data-book='{1}' lang='en'>{2}</{0}>","div",key,dataDivValue);
			}
			html += "</div>";//end of datadiv
			html += existingLicenseBlockOnPage;
			html += "</body></html>";
			var bookDom = new HtmlDom(html);

			BookCopyrightAndLicense.UpdateDomFromDataDiv(bookDom,"", _collectionSettings);
			string valuePredicate;
			if (key == "licenseImage")
			{
				valuePredicate = string.IsNullOrEmpty(dataDivValue) ? "@src=''" : "@src='" + dataDivValue + "'";
			}
			else
			{
				valuePredicate = string.IsNullOrEmpty(dataDivValue) ? "(text()='' or not(text()))" : "text()='" + dataDivValue + "'";
			}
			var xpath = "//div[@id='test']/*[@data-derived='" + key + "' and " + valuePredicate + "]";
			if(!string.IsNullOrEmpty(customXPath))
			{
				xpath = customXPath;
			}
			try
			{
				AssertThatXmlIn.Dom(bookDom.RawDom).HasSpecifiedNumberOfMatchesForXpath(xpath, 1);
			}
			catch (AssertionException)
			{
				Console.WriteLine("xpath was:" + xpath);
				Assert.Fail(description);
			}
		}
	}
BookCopyrightAndLicenseTests