Skip to content

Commit

Permalink
Fixing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
majiccode committed Oct 4, 2017
1 parent 0879d62 commit 1a78d03
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 38 deletions.
12 changes: 6 additions & 6 deletions Sdl.Web.Tridion.Tests/ContentProviderTest.cs
Expand Up @@ -202,8 +202,8 @@ public void GetPageModel_RichTextProcessing_Success()
string firstHtmlFragment = content.Fragments.First().ToHtml();
Assert.IsNotNull(firstHtmlFragment, "firstHtmlFragment");
StringAssert.Matches(firstHtmlFragment, new Regex(@"Component link \(not published\): Test Component"));
StringAssert.Matches(firstHtmlFragment, new Regex(@"Component link \(published\): <a title=""TSI-1758 Test Component"" href=""/autotest-parent/regression/tsi-1758"">TSI-1758 Test Component</a>"));
StringAssert.Matches(firstHtmlFragment, new Regex(@"MMC link: <a title=""bulls-eye"" href=""/autotest-parent/Images/bulls-eye.*"">bulls-eye</a>"));
StringAssert.Matches(firstHtmlFragment, new Regex(@"Component link \(published\): <a title=""TSI-1758 Test Component"" href=""/autotest-parent-legacy/regression/tsi-1758"">TSI-1758 Test Component</a>"));
StringAssert.Matches(firstHtmlFragment, new Regex(@"MMC link: <a title=""bulls-eye"" href=""/autotest-parent-legacy/Images/bulls-eye.*"">bulls-eye</a>"));
}

[TestMethod]
Expand Down Expand Up @@ -465,10 +465,10 @@ private static void AssertValidKeywordModel(KeywordModel keywordModel, string ex
Assert.AreEqual(15, pageMeta.Count, "pageMeta.Count");
Assert.AreEqual("This is single line text", pageMeta["singleLineText"], "pageMeta[singleLineText]");
Assert.AreEqual("This is multi line text line 1\nAnd line 2\n", pageMeta["multiLineText"], "pageMeta[multiLineText]");
Assert.AreEqual("This is <strong>rich</strong> text with a <a title=\"Test Article\" href=\"/autotest-parent/test_article_dynamic\">Component Link</a>", pageMeta["richText"], "pageMeta[richText]");
Assert.AreEqual("This is <strong>rich</strong> text with a <a title=\"Test Article\" href=\"/autotest-parent-legacy/test_article_dynamic\">Component Link</a>", pageMeta["richText"], "pageMeta[richText]");
Assert.AreEqual("News Article", pageMeta["keyword"], "pageMeta[keyword]");
Assert.AreEqual("/autotest-parent/test_article_dynamic", pageMeta["componentLink"], "pageMeta[componentLink]");
Assert.AreEqual("/autotest-parent/Images/company-news-placeholder_tcm1065-4480.png", pageMeta["mmComponentLink"], "pageMeta[mmComponentLink]");
Assert.AreEqual("/autotest-parent-legacy/test_article_dynamic", pageMeta["componentLink"], "pageMeta[componentLink]");
Assert.AreEqual("/autotest-parent-legacy/Images/company-news-placeholder_tcm1081-4480.png", pageMeta["mmComponentLink"], "pageMeta[mmComponentLink]");
Assert.AreEqual("1970-12-16T12:34:56", pageMeta["date"], "pageMeta[date]");
Assert.AreEqual("666.666", pageMeta["number"], "pageMeta[number]");
Assert.AreEqual("Rick Pannekoek", pageMeta["author"], "pageMeta[author]");
Expand Down Expand Up @@ -511,7 +511,7 @@ private static void AssertValidKeywordModel(KeywordModel keywordModel, string ex

Common.Models.Configuration configEntity = pageModel.Regions["Nav"].Entities[0] as Common.Models.Configuration;
Assert.IsNotNull(configEntity, "configEntity");
Assert.AreEqual("tcm:1065-9712", configEntity.Settings["defaultContentLink"], "configEntity.Settings['defaultCOntentLink']");
Assert.AreEqual("tcm:1081-9712", configEntity.Settings["defaultContentLink"], "configEntity.Settings['defaultCOntentLink']");
Assert.AreEqual("pt,mx", configEntity.Settings["suppressLocalizations"], "configEntity.Settings['suppressLocalizations']");
}

Expand Down
10 changes: 5 additions & 5 deletions Sdl.Web.Tridion.Tests/DynamicNavigationProviderTest.cs
Expand Up @@ -106,16 +106,16 @@ public void GetTopNavigationLinks_Root_Success()
OutputJson(navLinks);

Assert.AreEqual(1, navLinks.Items.Count, "navLinks.Items.Count");
AssertValidLink(navLinks.Items[0], "/autotest-parent/regression/taxonomy", TestFixture.TopLevelKeyword2Title, "Top-level Keyword 2 (concrete)", "navLinks.Items[0]");
AssertValidLink(navLinks.Items[0], "/autotest-parent-legacy/regression/taxonomy", TestFixture.TopLevelKeyword2Title, "Top-level Keyword 2 (concrete)", "navLinks.Items[0]");
}

private static void AssertExpectedLinks(IList<Link> links)
{
Assert.IsNotNull(links, "links");
Assert.AreEqual(3, links.Count, "links.Count");
AssertValidLink(links[0], "/autotest-parent/regression/taxonomy/index", "Navigation Taxonomy Index Page", null, "links[0]");
AssertValidLink(links[1], "/autotest-parent/regression/taxonomy/nav-taxonomy-test-2", "Navigation Taxonomy Test Page 2", null, "links[1]");
AssertValidLink(links[2], "/autotest-parent/regression/taxonomy/nav-taxonomy-test-1", "Navigation Taxonomy Test Page 1", null, "links[2]");
AssertValidLink(links[0], "/autotest-parent-legacy/regression/taxonomy/index", "Navigation Taxonomy Index Page", null, "links[0]");
AssertValidLink(links[1], "/autotest-parent-legacy/regression/taxonomy/nav-taxonomy-test-2", "Navigation Taxonomy Test Page 2", null, "links[1]");
AssertValidLink(links[2], "/autotest-parent-legacy/regression/taxonomy/nav-taxonomy-test-1", "Navigation Taxonomy Test Page 1", null, "links[2]");
}

[TestMethod]
Expand Down Expand Up @@ -194,7 +194,7 @@ public void GetBreadcrumbNavigationLinks_TaxonomyTestPage1_Success()
AssertValidLink(navLinks.Items[0], null, TestFixture.TopLevelKeyword1Title, "Top-level Keyword 1 (abstract)", "navLinks.Items[0]");
AssertValidLink(navLinks.Items[1], null, "Keyword 1.1", "First child Keyword of Top-level Keyword 1", "navLinks.Items[1]");
AssertValidLink(navLinks.Items[2], null, "Keyword 1.1.2", "Second child Keyword of Keyword 1.1", "navLinks.Items[2]");
AssertValidLink(navLinks.Items[3], "/autotest-parent/regression/taxonomy/nav-taxonomy-test-1", "Navigation Taxonomy Test Page 1", null, "navLinks.Items[3]");
AssertValidLink(navLinks.Items[3], "/autotest-parent-legacy/regression/taxonomy/nav-taxonomy-test-1", "Navigation Taxonomy Test Page 1", null, "navLinks.Items[3]");
}

[TestMethod]
Expand Down
42 changes: 21 additions & 21 deletions Sdl.Web.Tridion.Tests/TestFixture.cs
Expand Up @@ -15,23 +15,23 @@ internal class TestFixture : ILocalizationResolver
{
internal const string HomePageId = "640";
internal const string ArticleDcpEntityId = "9712-9711";
internal const string ArticlePageUrlPath = "/autotest-parent/test_article_page.html";
internal const string ArticleChildPageUrlPath = "/autotest-child/test_article_page.html";
internal const string ArticleDynamicPageUrlPath = "/autotest-parent/test_article_dynamic.html";
internal const string MediaManagerTestPageUrlPath = "/autotest-parent/mm_test.html";
internal const string Tsi1278PageUrlPath = "/autotest-parent/tsi-1278_trådløst.html";
internal const string Tsi1278StaticContentItemUrlPath = "/autotest-parent/Images/trådløst_tcm1065-9791.jpg";
internal const string Tsi1614PageUrlPath = "/autotest-parent/tsi-1614.html";
internal const string Tsi1758PageUrlPath = "/autotest-parent/regression/tsi-1758.html";
internal const string Tsi1852PageUrlPath = "/autotest-parent/regression/tsi-1852.html";
internal const string Tsi1946PageUrlPath = "/autotest-parent/regression/tsi-1946.html";
internal const string Tsi811PageUrlPath = "/autotest-parent/regression/tsi-811";
internal const string Tsi1308PageUrlPath = "/autotest-parent/regression/tsi-1308";
internal const string Tsi1757PageUrlPath = "/autotest-child/regression/tsi-1757";
internal const string Tsi2225PageUrlPath = "/autotest-parent/regression/tsi-2225";
internal const string TaxonomyTestPage1UrlPath = "/autotest-parent/regression/taxonomy/nav-taxonomy-test-1.html";
internal const string TaxonomyTestPage2UrlPath = "/autotest-parent/regression/taxonomy/nav-taxonomy-test-2.html";
internal const string TaxonomyIndexPageUrlPath = "/autotest-parent/regression/taxonomy";
internal const string ArticlePageUrlPath = "/autotest-parent-legacy/test_article_page.html";
internal const string ArticleChildPageUrlPath = "/autotest-child-legacy/test_article_page.html";
internal const string ArticleDynamicPageUrlPath = "/autotest-parent-legacy/test_article_dynamic.html";
internal const string MediaManagerTestPageUrlPath = "/autotest-parent-legacy/mm_test.html";
internal const string Tsi1278PageUrlPath = "/autotest-parent-legacy/tsi-1278_trådløst.html";
internal const string Tsi1278StaticContentItemUrlPath = "/autotest-parent-legacy/Images/trådløst_tcm1081-9791.jpg";
internal const string Tsi1614PageUrlPath = "/autotest-parent-legacy/tsi-1614.html";
internal const string Tsi1758PageUrlPath = "/autotest-parent-legacy/regression/tsi-1758.html";
internal const string Tsi1852PageUrlPath = "/autotest-parent-legacy/regression/tsi-1852.html";
internal const string Tsi1946PageUrlPath = "/autotest-parent-legacy/regression/tsi-1946.html";
internal const string Tsi811PageUrlPath = "/autotest-parent-legacy/regression/tsi-811";
internal const string Tsi1308PageUrlPath = "/autotest-parent-legacy/regression/tsi-1308";
internal const string Tsi1757PageUrlPath = "/autotest-child-legacy/regression/tsi-1757";
internal const string Tsi2225PageUrlPath = "/autotest-parent-legacy/regression/tsi-2225";
internal const string TaxonomyTestPage1UrlPath = "/autotest-parent-legacy/regression/taxonomy/nav-taxonomy-test-1.html";
internal const string TaxonomyTestPage2UrlPath = "/autotest-parent-legacy/regression/taxonomy/nav-taxonomy-test-2.html";
internal const string TaxonomyIndexPageUrlPath = "/autotest-parent-legacy/regression/taxonomy";
internal const string NavigationTaxonomyTitle = "Test Taxonomy [Navigation]";
internal const string TopLevelKeyword1Title = "Top-level Keyword 1";
internal const string TopLevelKeyword2Title = "Top-level Keyword 2";
Expand Down Expand Up @@ -61,14 +61,14 @@ static TestFixture()

_parentLocalization = new Localization
{
LocalizationId = "1065",
Path = "/autotest-parent"
LocalizationId = "1081",
Path = "/autotest-parent-legacy"
};

_childLocalization = new Localization
{
LocalizationId = "1078",
Path = "/autotest-child"
LocalizationId = "1083",
Path = "/autotest-child-legacy"
};

_testLocalizations = new[] { _parentLocalization, _childLocalization };
Expand Down
7 changes: 1 addition & 6 deletions Sdl.Web.Tridion/Statics/BinaryFileManager.cs
Expand Up @@ -116,12 +116,7 @@ internal string GetCachedFile(string urlPath, Localization localization)
// Binary does not exist or cached binary is out-of-date
BinaryMeta binaryMeta = GetBinaryMeta(urlPath, publicationId);
if (binaryMeta == null)
{
// Binary does not exist in Tridion, it should be removed from the local file system too
if (File.Exists(localFilePath))
{
CleanupLocalFile(localFilePath);
}
{
throw new DxaItemNotFoundException(urlPath, localization.LocalizationId);
}
BinaryFactory binaryFactory = new BinaryFactory();
Expand Down

0 comments on commit 1a78d03

Please sign in to comment.