Skip to content

Commit

Permalink
Merge branch 'main' into Feature/ContainerizeRegressionTests
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgnagepatil committed Sep 21, 2023
2 parents f852314 + ffd307d commit 7a7c18a
Show file tree
Hide file tree
Showing 20 changed files with 482 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class EntityResolverTests
[TestCase("detailedPathway", typeof(DetailedPathway))]
[TestCase("detailedRole", typeof(DetailedRole))]
[TestCase("heroBanner", typeof(HeroBanner))]
[TestCase("imageCard", typeof(ImageCard))]
[TestCase("linkCard", typeof(LinkCard))]
[TestCase("linkListCard", typeof(LinkListCard))]
[TestCase("richTextBlock", typeof(RichTextBlock))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public partial class PartialsFactoryTests
new object[] { new DetailedRole(), "_DetailedRole" },
new object[] { new HeroBanner(), string.Empty },
new object[] { new LinkCard(), "_LinkCard" },
new object[] { new ImageCard(), "_ImageCard" },
new object[] { new LinkListCard(), "_LinkListCard" },
new object[] { new RichTextBlock(), "_RichTextBlock" },
new object[] { new RoleList(), "_RoleList" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Childrens_Social_Care_CPD.Contentful.Renderers;
using Childrens_Social_Care_CPD.Contentful.Models;
using Childrens_Social_Care_CPD.Contentful.Renderers;
using Contentful.Core.Models;
using FluentAssertions;
using Microsoft.AspNetCore.Html;
Expand All @@ -14,14 +15,16 @@ public class Heading1RendererTests
{
private IRenderer<Text> _textRenderer;
private IRenderer<Hyperlink> _hyperlinkRenderer;
private IRenderer<ContentLink> _contentLinkRenderer;
private Heading1Renderer _sut;

[SetUp]
public void Setup()
{
_textRenderer = Substitute.For<IRenderer<Text>>();
_hyperlinkRenderer = Substitute.For<IRenderer<Hyperlink>>();
_sut = new Heading1Renderer(_textRenderer, _hyperlinkRenderer);
_contentLinkRenderer = Substitute.For<IRenderer<ContentLink>>();
_sut = new Heading1Renderer(_textRenderer, _hyperlinkRenderer, _contentLinkRenderer);
}

[Test]
Expand Down Expand Up @@ -78,4 +81,36 @@ public void Heading1_Renders_Hyperlink()
// assert
actual.Should().Be("<h1>AAA</h1>");
}

[Test]
public void Heading1_Renders_ContentLink()
{
// arrange
var stringWriter = new StringWriter();
var contentLink = new ContentLink();

var heading1 = new Heading1()
{
Content = new List<IContent> {
new EntryStructure
{
Data = new EntryStructureData
{
Target = contentLink
}
}
}
};

_contentLinkRenderer.Render(contentLink).Returns(new HtmlString("AAA"));

// act
var htmlContent = _sut.Render(heading1);
htmlContent.WriteTo(stringWriter, new HtmlTestEncoder());
var actual = stringWriter.ToString();

// assert
actual.Should().Be("<h1>AAA</h1>");
}
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Childrens_Social_Care_CPD.Contentful.Renderers;
using Childrens_Social_Care_CPD.Contentful.Models;
using Childrens_Social_Care_CPD.Contentful.Renderers;
using Contentful.Core.Models;
using FluentAssertions;
using Microsoft.AspNetCore.Html;
Expand All @@ -14,14 +15,16 @@ public class Heading2RendererTests
{
private IRenderer<Text> _textRenderer;
private IRenderer<Hyperlink> _hyperlinkRenderer;
private IRenderer<ContentLink> _contentLinkRenderer;
private Heading2Renderer _sut;

[SetUp]
public void Setup()
{
_textRenderer = Substitute.For<IRenderer<Text>>();
_hyperlinkRenderer = Substitute.For<IRenderer<Hyperlink>>();
_sut = new Heading2Renderer(_textRenderer, _hyperlinkRenderer);
_contentLinkRenderer = Substitute.For<IRenderer<ContentLink>>();
_sut = new Heading2Renderer(_textRenderer, _hyperlinkRenderer, _contentLinkRenderer);
}

[Test]
Expand Down Expand Up @@ -78,4 +81,35 @@ public void Heading2_Renders_Hyperlink()
// assert
actual.Should().Be("<h2>AAA</h2>");
}

[Test]
public void Heading2_Renders_ContentLink()
{
// arrange
var stringWriter = new StringWriter();
var contentLink = new ContentLink();

var heading2 = new Heading2()
{
Content = new List<IContent> {
new EntryStructure
{
Data = new EntryStructureData
{
Target = contentLink
}
}
}
};

_contentLinkRenderer.Render(contentLink).Returns(new HtmlString("AAA"));

// act
var htmlContent = _sut.Render(heading2);
htmlContent.WriteTo(stringWriter, new HtmlTestEncoder());
var actual = stringWriter.ToString();

// assert
actual.Should().Be("<h2>AAA</h2>");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Childrens_Social_Care_CPD.Contentful.Renderers;
using Childrens_Social_Care_CPD.Contentful.Models;
using Childrens_Social_Care_CPD.Contentful.Renderers;
using Contentful.Core.Models;
using FluentAssertions;
using Microsoft.AspNetCore.Html;
Expand All @@ -14,14 +15,16 @@ public class Heading3RendererTests
{
private IRenderer<Text> _textRenderer;
private IRenderer<Hyperlink> _hyperlinkRenderer;
private IRenderer<ContentLink> _contentLinkRenderer;
private Heading3Renderer _sut;

[SetUp]
public void Setup()
{
_textRenderer = Substitute.For<IRenderer<Text>>();
_hyperlinkRenderer = Substitute.For<IRenderer<Hyperlink>>();
_sut = new Heading3Renderer(_textRenderer, _hyperlinkRenderer);
_contentLinkRenderer = Substitute.For<IRenderer<ContentLink>>();
_sut = new Heading3Renderer(_textRenderer, _hyperlinkRenderer, _contentLinkRenderer);
}

[Test]
Expand Down Expand Up @@ -78,4 +81,35 @@ public void Heading3_Renders_Hyperlink()
// assert
actual.Should().Be("<h3>AAA</h3>");
}

[Test]
public void Heading3_Renders_ContentLink()
{
// arrange
var stringWriter = new StringWriter();
var contentLink = new ContentLink();

var heading3 = new Heading3()
{
Content = new List<IContent> {
new EntryStructure
{
Data = new EntryStructureData
{
Target = contentLink
}
}
}
};

_contentLinkRenderer.Render(contentLink).Returns(new HtmlString("AAA"));

// act
var htmlContent = _sut.Render(heading3);
htmlContent.WriteTo(stringWriter, new HtmlTestEncoder());
var actual = stringWriter.ToString();

// assert
actual.Should().Be("<h3>AAA</h3>");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Childrens_Social_Care_CPD.Contentful.Renderers;
using Childrens_Social_Care_CPD.Contentful.Models;
using Childrens_Social_Care_CPD.Contentful.Renderers;
using Contentful.Core.Models;
using FluentAssertions;
using Microsoft.AspNetCore.Html;
Expand All @@ -14,14 +15,16 @@ public class Heading4RendererTests
{
private IRenderer<Text> _textRenderer;
private IRenderer<Hyperlink> _hyperlinkRenderer;
private IRenderer<ContentLink> _contentLinkRenderer;
private Heading4Renderer _sut;

[SetUp]
public void Setup()
{
_textRenderer = Substitute.For<IRenderer<Text>>();
_hyperlinkRenderer = Substitute.For<IRenderer<Hyperlink>>();
_sut = new Heading4Renderer(_textRenderer, _hyperlinkRenderer);
_contentLinkRenderer = Substitute.For<IRenderer<ContentLink>>();
_sut = new Heading4Renderer(_textRenderer, _hyperlinkRenderer, _contentLinkRenderer);
}

[Test]
Expand Down Expand Up @@ -78,4 +81,35 @@ public void Heading4_Renders_Hyperlink()
// assert
actual.Should().Be("<h4>AAA</h4>");
}

[Test]
public void Heading4_Renders_ContentLink()
{
// arrange
var stringWriter = new StringWriter();
var contentLink = new ContentLink();

var heading4 = new Heading4()
{
Content = new List<IContent> {
new EntryStructure
{
Data = new EntryStructureData
{
Target = contentLink
}
}
}
};

_contentLinkRenderer.Render(contentLink).Returns(new HtmlString("AAA"));

// act
var htmlContent = _sut.Render(heading4);
htmlContent.WriteTo(stringWriter, new HtmlTestEncoder());
var actual = stringWriter.ToString();

// assert
actual.Should().Be("<h4>AAA</h4>");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Childrens_Social_Care_CPD.Contentful.Renderers;
using Childrens_Social_Care_CPD.Contentful.Models;
using Childrens_Social_Care_CPD.Contentful.Renderers;
using Contentful.Core.Models;
using FluentAssertions;
using Microsoft.AspNetCore.Html;
Expand All @@ -14,14 +15,16 @@ public class Heading5RendererTests
{
private IRenderer<Text> _textRenderer;
private IRenderer<Hyperlink> _hyperlinkRenderer;
private IRenderer<ContentLink> _contentLinkRenderer;
private Heading5Renderer _sut;

[SetUp]
public void Setup()
{
_textRenderer = Substitute.For<IRenderer<Text>>();
_hyperlinkRenderer = Substitute.For<IRenderer<Hyperlink>>();
_sut = new Heading5Renderer(_textRenderer, _hyperlinkRenderer);
_contentLinkRenderer = Substitute.For<IRenderer<ContentLink>>();
_sut = new Heading5Renderer(_textRenderer, _hyperlinkRenderer, _contentLinkRenderer);
}

[Test]
Expand Down Expand Up @@ -78,4 +81,35 @@ public void Heading5_Renders_Hyperlink()
// assert
actual.Should().Be("<h5>AAA</h5>");
}

[Test]
public void Heading5_Renders_ContentLink()
{
// arrange
var stringWriter = new StringWriter();
var contentLink = new ContentLink();

var heading5 = new Heading5()
{
Content = new List<IContent> {
new EntryStructure
{
Data = new EntryStructureData
{
Target = contentLink
}
}
}
};

_contentLinkRenderer.Render(contentLink).Returns(new HtmlString("AAA"));

// act
var htmlContent = _sut.Render(heading5);
htmlContent.WriteTo(stringWriter, new HtmlTestEncoder());
var actual = stringWriter.ToString();

// assert
actual.Should().Be("<h5>AAA</h5>");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Childrens_Social_Care_CPD.Contentful.Renderers;
using Childrens_Social_Care_CPD.Contentful.Models;
using Childrens_Social_Care_CPD.Contentful.Renderers;
using Contentful.Core.Models;
using FluentAssertions;
using Microsoft.AspNetCore.Html;
Expand All @@ -14,14 +15,16 @@ public class Heading6RendererTests
{
private IRenderer<Text> _textRenderer;
private IRenderer<Hyperlink> _hyperlinkRenderer;
private IRenderer<ContentLink> _contentLinkRenderer;
private Heading6Renderer _sut;

[SetUp]
public void Setup()
{
_textRenderer = Substitute.For<IRenderer<Text>>();
_hyperlinkRenderer = Substitute.For<IRenderer<Hyperlink>>();
_sut = new Heading6Renderer(_textRenderer, _hyperlinkRenderer);
_contentLinkRenderer = Substitute.For<IRenderer<ContentLink>>();
_sut = new Heading6Renderer(_textRenderer, _hyperlinkRenderer, _contentLinkRenderer);
}

[Test]
Expand Down Expand Up @@ -78,4 +81,35 @@ public void Heading6_Renders_Hyperlink()
// assert
actual.Should().Be("<h6>AAA</h6>");
}

[Test]
public void Heading6_Renders_ContentLink()
{
// arrange
var stringWriter = new StringWriter();
var contentLink = new ContentLink();

var heading6 = new Heading6()
{
Content = new List<IContent> {
new EntryStructure
{
Data = new EntryStructureData
{
Target = contentLink
}
}
}
};

_contentLinkRenderer.Render(contentLink).Returns(new HtmlString("AAA"));

// act
var htmlContent = _sut.Render(heading6);
htmlContent.WriteTo(stringWriter, new HtmlTestEncoder());
var actual = stringWriter.ToString();

// assert
actual.Should().Be("<h6>AAA</h6>");
}
}
1 change: 1 addition & 0 deletions Childrens-Social-Care-CPD/Contentful/EntityResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public Type Resolve(string contentTypeId)
"detailedPathway" => typeof(DetailedPathway),
"detailedRole" => typeof(DetailedRole),
"heroBanner" => typeof(HeroBanner),
"imageCard" => typeof(ImageCard),
"linkCard" => typeof(LinkCard),
"linkListCard" => typeof(LinkListCard),
"richTextBlock" => typeof(RichTextBlock),
Expand Down
Loading

0 comments on commit 7a7c18a

Please sign in to comment.