public void ExtractContractEventsFromFeedPageAsyncTest() { //Arrange var dummyPayload = @"<?xml version=""1.0"" encoding=""utf-8""?> <feed xmlns=""http://www.w3.org/2005/Atom""> <title type=""text"">Test</title> <id>uuid:d2619398-19dc-44e8-b4a9-917796baf6c2</id> <updated>2021-01-01T01:01:01Z</updated> <author> <name>Contract Management Service</name> </author> <link rel=""next-archive"" type=""application/vnd.test.v1+atom+xml"" href=""https://localhost/notifications/3"" /> <link rel=""prev-archive"" type=""application/vnd.test.v1+atom+xml"" href=""https://localhost/notifications/1"" /> <link rel=""self"" type=""application/vnd.test.v1+atom+xml"" href=""https://localhost/notifications"" /> <link rel=""current"" type=""application/vnd.test.v1+atom+xml"" href=""https://localhost/notifications/2"" /> <archive xmlns=""http://purl.org/syndication/history/1.0""></archive> <entry> <id>uuid:d2619398-19dc-44e8-b4a9-917796baf6c2</id> <title type=""text"">Test title</title> <summary type=""text"">Test summary</summary> <published>2021-01-01T01:01:01Z</published> <updated>2021-01-01T01:01:01Z</updated> <category term=""Test category"" label=""A test category"" /> <content type=""application/vnd.test.v1+atom+xml"">Test content string</content> </entry> </feed>"; var expectedFeedPage = new FeedPage { CurrentPageNumber = 2, PreviousPageNumber = 1, NextPageNumber = 3, IsSelfPage = false, Entries = new[] { new FeedEntry { Id = new Guid("d2619398-19dc-44e8-b4a9-917796baf6c2"), Updated = DateTime.Parse("2021-01-01T01:01:01Z"), Content = @"<Content type=""application/vnd.test.v1+atom+xml"">Test content string</Content>" } } }; Mock.Get(_mockMapper) .Setup(m => m.Map <IList <FeedEntry> >(It.IsAny <IEnumerable <SyndicationItem> >())) .Returns(expectedFeedPage.Entries); //Act var reader = new FcsFeedReaderService(_mockAuthService, _mockHttpClient, _mockMapper, _mockOptions); var results = reader.ExtractContractEventsFromFeedPageAsync(dummyPayload); //Assert results.Should().BeEquivalentTo(expectedFeedPage); }
public async Task ReadSelfPageAsyncTestAsync() { //Arrange var dummyPayload = @"<?xml version=""1.0"" encoding=""utf-8""?> <feed xmlns=""http://www.w3.org/2005/Atom""> <title type=""text"">Test</title> <id>uuid:d2619398-19dc-44e8-b4a9-917796baf6c2</id> <updated>2021-01-01T01:01:01Z</updated> <author> <name>Contract Management Service</name> </author> <link rel=""prev-archive"" type=""application/vnd.test.v1+atom+xml"" href=""https://localhost/notifications/1"" /> <link rel=""self"" type=""application/vnd.test.v1+atom+xml"" href=""https://localhost/notifications"" /> <archive xmlns=""http://purl.org/syndication/history/1.0""></archive> <entry> <id>uuid:d2619398-19dc-44e8-b4a9-917796baf6c2</id> <title type=""text"">Test title</title> <summary type=""text"">Test summary</summary> <published>2021-01-01T01:01:01Z</published> <updated>2021-01-01T01:01:01Z</updated> <category term=""Test category"" label=""A test category"" /> <content type=""application/vnd.test.v1+atom+xml"">Test content string</content> </entry> </feed>"; var expectedFeedPage = new FeedPage { CurrentPageNumber = 2, PreviousPageNumber = 1, IsSelfPage = true, Entries = new[] { new FeedEntry { Id = new Guid("d2619398-19dc-44e8-b4a9-917796baf6c2"), Updated = DateTime.Parse("2021-01-01T01:01:01Z"), Content = @"<Content type=""application/vnd.test.v1+atom+xml"">Test content string</Content>" } } }; SetupMocks(dummyPayload, expectedFeedPage); //Act var reader = new FcsFeedReaderService(_mockAuthService, _mockHttpClient, _mockMapper, _mockOptions); var results = await reader.ReadSelfPageAsync(); //Assert results.Should().BeEquivalentTo(expectedFeedPage); VerifyMocks(); }