2
2
using System . Text ;
3
3
using System . Threading . Tasks ;
4
4
using LinkDotNet . Blog . Domain ;
5
+ using LinkDotNet . Blog . Infrastructure . Persistence . InMemory ;
5
6
using LinkDotNet . Blog . TestUtilities ;
6
7
using LinkDotNet . Blog . Web ;
7
8
using LinkDotNet . Blog . Web . Controller ;
10
11
11
12
namespace LinkDotNet . Blog . IntegrationTests . Web . Controller ;
12
13
13
- public class RssFeedControllerTests : SqlDatabaseTestBase < BlogPost >
14
+ public class RssFeedControllerTests
14
15
{
15
16
[ Fact ]
16
17
public async Task ShouldCreateRssFeed ( )
17
18
{
19
+ var repository = new Repository < BlogPost > ( ) ;
18
20
var request = new Mock < HttpRequest > ( ) ;
19
21
request . Setup ( x => x . Scheme ) . Returns ( "http" ) ;
20
22
request . Setup ( x => x . Host ) . Returns ( new HostString ( "localhost" ) ) ;
@@ -37,14 +39,16 @@ public async Task ShouldCreateRssFeed()
37
39
. WithShortDescription ( "Short 1" )
38
40
. WithUpdatedDate ( new DateTime ( 2022 , 5 , 1 ) )
39
41
. Build ( ) ;
42
+ blogPost1 . Id = "1" ;
40
43
var blogPost2 = new BlogPostBuilder ( )
41
44
. WithTitle ( "2" )
42
45
. WithShortDescription ( "Short 2" )
43
46
. WithUpdatedDate ( new DateTime ( 2022 , 6 , 1 ) )
44
47
. 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 )
48
52
{
49
53
ControllerContext = controllerContext ,
50
54
} ;
@@ -53,6 +57,6 @@ public async Task ShouldCreateRssFeed()
53
57
54
58
xml . Should ( ) . NotBeNull ( ) ;
55
59
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>" ) ;
57
61
}
58
62
}
0 commit comments