-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from ernado-x/net8
Add support for .NET 8
- Loading branch information
Showing
12 changed files
with
217 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 9 additions & 13 deletions
22
tests/X.Web.Sitemap.Tests/UnitTests/SerializedXmlSaver/DeserializeTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Xunit; | ||
|
||
namespace X.Web.Sitemap.Tests.UnitTests.SerializedXmlSaver; | ||
|
||
[TestFixture] | ||
public class DeserializeTests | ||
{ | ||
[Test] | ||
public void Check_That_XmlFile_Deserialized() | ||
{ | ||
var xml = File.ReadAllText("Data/example.xml"); | ||
var sitemap = Sitemap.Parse(xml); | ||
Assert.NotNull(sitemap); | ||
} | ||
[Fact] | ||
public void Check_That_XmlFile_Deserialized() | ||
{ | ||
var xml = File.ReadAllText("Data/example.xml"); | ||
var sitemap = Sitemap.Parse(xml); | ||
|
||
Assert.NotNull(sitemap); | ||
} | ||
} |
116 changes: 55 additions & 61 deletions
116
tests/X.Web.Sitemap.Tests/UnitTests/SerializedXmlSaver/SerializeAndSaveTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,61 @@ | ||
using NUnit.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Xml.Serialization; | ||
using Xunit; | ||
|
||
namespace X.Web.Sitemap.Tests.UnitTests.SerializedXmlSaver; | ||
|
||
[TestFixture] | ||
public class SerializeAndSaveTests | ||
{ | ||
private IFileSystemWrapper _fileSystemWrapper; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
_fileSystemWrapper = new TestFileSystemWrapper(); | ||
} | ||
|
||
//--this is a half-assed test as comparing the full XML string that is generated is a big pain. | ||
[Test] | ||
public void It_Saves_The_XML_File_To_The_Correct_Directory_And_File_Name() | ||
{ | ||
//--arrange | ||
var sitemapIndex = new SitemapIndex(new List<SitemapInfo> | ||
{ | ||
new SitemapInfo(new Uri("http://example.com/sitemap1.xml"), DateTime.UtcNow), | ||
new SitemapInfo(new Uri("http://example.com/sitemap2.xml"), DateTime.UtcNow.AddDays(-1)) | ||
}); | ||
|
||
var fileName = "sitemapindex.xml"; | ||
var directory = new DirectoryInfo("x"); | ||
var path = Path.Combine(directory.FullName, fileName); | ||
|
||
var serializer = new SitemapIndexSerializer(); | ||
var xml = serializer.Serialize(sitemapIndex); | ||
|
||
//--act | ||
var result = _fileSystemWrapper.WriteFile(xml, path); | ||
|
||
Assert.True(result.FullName.Contains("sitemapindex")); | ||
Assert.AreEqual(directory.Name, result.Directory.Name); | ||
Assert.AreEqual(fileName, result.Name); | ||
} | ||
|
||
[Test] | ||
public void It_Returns_A_File_Info_For_The_File_That_Was_Created() | ||
{ | ||
//--arrange | ||
var expectedFileInfo = new FileInfo("something/file.xml"); | ||
var sitemapIndex = new SitemapIndex(new List<SitemapInfo>()); | ||
|
||
var serializer = new SitemapIndexSerializer(); | ||
var xml = serializer.Serialize(sitemapIndex); | ||
|
||
var fileName = "file.xml"; | ||
var directory = new DirectoryInfo("something"); | ||
var path = Path.Combine(directory.FullName, fileName); | ||
|
||
//--act | ||
var result = _fileSystemWrapper.WriteFile(xml, path); | ||
|
||
Assert.AreEqual(expectedFileInfo.FullName, result.FullName); | ||
Assert.AreEqual(expectedFileInfo.Directory, result.Directory); | ||
} | ||
|
||
private IFileSystemWrapper _fileSystemWrapper; | ||
|
||
public SerializeAndSaveTests() | ||
{ | ||
_fileSystemWrapper = new TestFileSystemWrapper(); | ||
} | ||
|
||
[Fact] | ||
public void It_Saves_The_XML_File_To_The_Correct_Directory_And_File_Name() | ||
{ | ||
//--arrange | ||
var sitemapIndex = new SitemapIndex(new List<SitemapInfo> | ||
{ | ||
new SitemapInfo(new Uri("http://example.com/sitemap1.xml"), DateTime.UtcNow), | ||
new SitemapInfo(new Uri("http://example.com/sitemap2.xml"), DateTime.UtcNow.AddDays(-1)) | ||
}); | ||
|
||
var fileName = "sitemapindex.xml"; | ||
var directory = new DirectoryInfo("x"); | ||
var path = Path.Combine(directory.FullName, fileName); | ||
|
||
var serializer = new SitemapIndexSerializer(); | ||
var xml = serializer.Serialize(sitemapIndex); | ||
|
||
//--act | ||
var result = _fileSystemWrapper.WriteFile(xml, path); | ||
|
||
//--assert | ||
Assert.True(result.FullName.Contains("sitemapindex")); | ||
Assert.Equal(directory.Name, result.Directory.Name); | ||
Assert.Equal(fileName, result.Name); | ||
} | ||
|
||
[Fact] | ||
public void It_Returns_A_File_Info_For_The_File_That_Was_Created() | ||
{ | ||
//--arrange | ||
var expectedFileInfo = new FileInfo("something/file.xml"); | ||
var sitemapIndex = new SitemapIndex(new List<SitemapInfo>()); | ||
|
||
var serializer = new SitemapIndexSerializer(); | ||
var xml = serializer.Serialize(sitemapIndex); | ||
|
||
var fileName = "file.xml"; | ||
var directory = new DirectoryInfo("something"); | ||
var path = Path.Combine(directory.FullName, fileName); | ||
|
||
//--act | ||
var result = _fileSystemWrapper.WriteFile(xml, path); | ||
|
||
//--assert | ||
Assert.Equal(expectedFileInfo.FullName, result.FullName); | ||
Assert.Equal(expectedFileInfo.Directory.Name, result.Directory.Name); | ||
} | ||
} |
Oops, something went wrong.