Skip to content

Commit

Permalink
Update tests, update package settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
a-gubskiy committed Jul 22, 2024
1 parent 22f351f commit f94c482
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
12 changes: 7 additions & 5 deletions src/X.Web.RSS/RssDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,15 @@ public string ToXml()
}

public static RssDocument Load(Stream source)
{
{
var xsn = new XmlSerializerNamespaces();
xsn.Add("atom", "http://www.w3.org/2005/Atom");
xsn.Add("dc", "http://purl.org/dc/elements/1.1/");
xsn.Add("content", "http://purl.org/rss/1.0/modules/content/");

var ser = new XmlSerializer(typeof(RssDocument));
return (RssDocument)ser.Deserialize(source);
var serializer = new XmlSerializer(typeof(RssDocument));

return (RssDocument)serializer.Deserialize(source);
}

public static void WriteRSS(RssDocument value, Stream destination)
Expand All @@ -131,7 +132,8 @@ public static void WriteRSS(RssDocument value, Stream destination)
xsn.Add("dc", "http://purl.org/dc/elements/1.1/");
xsn.Add("content", "http://purl.org/rss/1.0/modules/content/");

var ser = new XmlSerializer(value.GetType());
ser.Serialize(destination, value, xsn);
var serializer = new XmlSerializer(value.GetType());

serializer.Serialize(destination, value, xsn);
}
}
12 changes: 4 additions & 8 deletions src/X.Web.RSS/X.Web.RSS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>

<Version>2.7.0</Version>
<AssemblyVersion>2.7.0.0</AssemblyVersion>
<FileVersion>2.7.0.0</FileVersion>
<Version>2.7.1</Version>
<AssemblyVersion>2.7.1.0</AssemblyVersion>
<FileVersion>2.7.1.0</FileVersion>
<LangVersion>default</LangVersion>
<Nullable>enable</Nullable>
<TargetFrameworks>net6.0;net8.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0;netstandard2.0;netstandard2.1</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -33,10 +33,6 @@

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2024.2.0" PrivateAssets="All"/>
<PackageReference Include="System.Net.Requests" Version="4.3.0" />
<PackageReference Include="System.Xml.XmlDocument" Version="4.3.0" />
<PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" />
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions tests/X.Web.RSS.Tests/RSSHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public void Read_External_Ok()
[Fact]
public void Test()
{
var request = WebRequest.Create("https://news.microsoft.com/feed/");
var request = WebRequest.Create("https://feeds.bbci.co.uk/news/world/rss.xml");
var response = request.GetResponse();
var stream = response.GetResponseStream();

var rss = RssDocument.Load(stream);

Assert.Equal("Stories", rss.Channel.Title);
Assert.Equal("Microsoft news, features, events, and press materials", rss.Channel.Description);
Assert.Equal("BBC News", rss.Channel.Title);
Assert.Equal("BBC News - World", rss.Channel.Description);
}

private static RssDocument GetFullRss()
Expand Down

0 comments on commit f94c482

Please sign in to comment.