Skip to content

Commit 25be8ad

Browse files
committed
Make test test something useful
1 parent a6aa933 commit 25be8ad

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tests/LinkDotNet.Blog.IntegrationTests/Web/Controller/RssFeedControllerTests.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Text;
33
using System.Threading.Tasks;
44
using LinkDotNet.Blog.Domain;
5+
using LinkDotNet.Blog.Infrastructure.Persistence.InMemory;
56
using LinkDotNet.Blog.TestUtilities;
67
using LinkDotNet.Blog.Web;
78
using LinkDotNet.Blog.Web.Controller;
@@ -10,11 +11,12 @@
1011

1112
namespace LinkDotNet.Blog.IntegrationTests.Web.Controller;
1213

13-
public class RssFeedControllerTests : SqlDatabaseTestBase<BlogPost>
14+
public class RssFeedControllerTests
1415
{
1516
[Fact]
1617
public async Task ShouldCreateRssFeed()
1718
{
19+
var repository = new Repository<BlogPost>();
1820
var request = new Mock<HttpRequest>();
1921
request.Setup(x => x.Scheme).Returns("http");
2022
request.Setup(x => x.Host).Returns(new HostString("localhost"));
@@ -37,14 +39,16 @@ public async Task ShouldCreateRssFeed()
3739
.WithShortDescription("Short 1")
3840
.WithUpdatedDate(new DateTime(2022, 5, 1))
3941
.Build();
42+
blogPost1.Id = "1";
4043
var blogPost2 = new BlogPostBuilder()
4144
.WithTitle("2")
4245
.WithShortDescription("Short 2")
4346
.WithUpdatedDate(new DateTime(2022, 6, 1))
4447
.Build();
45-
await Repository.StoreAsync(blogPost1);
46-
await Repository.StoreAsync(blogPost2);
47-
var cut = new RssFeedController(config, Repository)
48+
blogPost2.Id = "2";
49+
await repository.StoreAsync(blogPost1);
50+
await repository.StoreAsync(blogPost2);
51+
var cut = new RssFeedController(config, repository)
4852
{
4953
ControllerContext = controllerContext,
5054
};
@@ -53,6 +57,6 @@ public async Task ShouldCreateRssFeed()
5357

5458
xml.Should().NotBeNull();
5559
var content = Encoding.UTF8.GetString(xml.FileContents);
56-
content.Should().NotBeNull();
60+
content.Should().Contain("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<rss\r\n version=\"2.0\">\r\n <channel>\r\n <title>Test</title>\r\n <link>http://localhost/</link>\r\n <description>Description</description>\r\n <item>\r\n <guid\r\n isPermaLink=\"false\">2</guid>\r\n <link>http://localhost//blogPost/2</link>\r\n <title>2</title>\r\n <description>Short 2</description>\r\n <pubDate>Wed, 01 Jun 2022 00:00:00 +0200</pubDate>\r\n </item>\r\n <item>\r\n <guid\r\n isPermaLink=\"false\">1</guid>\r\n <link>http://localhost//blogPost/1</link>\r\n <title>1</title>\r\n <description>Short 1</description>\r\n <pubDate>Sun, 01 May 2022 00:00:00 +0200</pubDate>\r\n </item>\r\n </channel>\r\n</rss>");
5761
}
5862
}

0 commit comments

Comments
 (0)