Skip to content

Commit

Permalink
formatting error in ContentController.ServerTests.cs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria committed Dec 10, 2024
1 parent b228dc9 commit 8387947
Showing 1 changed file with 29 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using Childrens_Social_Care_CPD.Contentful.Models;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Childrens_Social_Care_CPD.Contentful.Models;
using Childrens_Social_Care_CPD_Tests.Contentful;
using Contentful.Core.Models;
using Contentful.Core.Search;
using FluentAssertions;
using Microsoft.AspNetCore.Mvc.Testing;
using NSubstitute;
using NUnit.Framework;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;

namespace Childrens_Social_Care_CPD_Tests.Controllers;

Expand All @@ -24,10 +24,9 @@ public class ContentControllerServerTests
public void SetUp()
{
_application = new CpdTestServerApplication();
_httpClient = _application.CreateClient(new WebApplicationFactoryClientOptions
{
AllowAutoRedirect = false
});
_httpClient = _application.CreateClient(
new WebApplicationFactoryClientOptions { AllowAutoRedirect = false }
);
}

[Test]
Expand All @@ -36,13 +35,21 @@ public async Task Content_Will_Contain_Warning_If_Data_Is_Self_Referential()
// arrange
var content = new Content();
content.Items = new List<IContent> { content };
var contentCollection = new ContentfulCollection<Content>() { Items = new List<Content>() { content } };
_application.CpdContentfulClient.GetEntries(Arg.Any<QueryBuilder<Content>>(), Arg.Any<CancellationToken>()).Returns(contentCollection);
var contentCollection = new ContentfulCollection<Content>()
{
Items = new List<Content>() { content }
};
_application
.CpdContentfulClient.GetEntries(
Arg.Any<QueryBuilder<Content>>(),
Arg.Any<CancellationToken>()
)
.Returns(contentCollection);

// act
var response = await _httpClient.GetAsync(_contentUrl);
var responseContent = await response.Content.ReadAsStringAsync();

// assert
response.StatusCode.Should().Be(HttpStatusCode.OK);
responseContent.Should().Contain("You have a circular link in your content");
Expand All @@ -52,12 +59,17 @@ public async Task Content_Will_Contain_Warning_If_Data_Is_Self_Referential()
public async Task Content_Will_Contain_Warning_If_Data_Has_An_Unknown_Content_Type()
{
// arrange
var content = new Content
var content = new Content { Items = new List<IContent> { new TestingContentItem() } };
var contentCollection = new ContentfulCollection<Content>()
{
Items = new List<IContent> { new TestingContentItem() }
Items = new List<Content>() { content }
};
var contentCollection = new ContentfulCollection<Content>() { Items = new List<Content>() { content } };
_application.CpdContentfulClient.GetEntries(Arg.Any<QueryBuilder<Content>>(), Arg.Any<CancellationToken>()).Returns(contentCollection);
_application
.CpdContentfulClient.GetEntries(
Arg.Any<QueryBuilder<Content>>(),
Arg.Any<CancellationToken>()
)
.Returns(contentCollection);

// act
var response = await _httpClient.GetAsync(_contentUrl);
Expand Down

0 comments on commit 8387947

Please sign in to comment.