This repository has been archived by the owner on Jun 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 197
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 #1 from tabro/master
Fixed failing unittests
- Loading branch information
Showing
5 changed files
with
57 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Serilog.Sinks.Elasticsearch.Tests | ||
{ | ||
public static class TestDataHelper | ||
{ | ||
public static string ReadEmbeddedResource( | ||
Assembly assembly, | ||
string embeddedResourceNameEndsWith) | ||
{ | ||
var resourceNames = assembly.GetManifestResourceNames(); | ||
var resourceName = resourceNames.SingleOrDefault(n => n.EndsWith(embeddedResourceNameEndsWith)); | ||
|
||
if (string.IsNullOrEmpty(resourceName)) | ||
{ | ||
throw new ArgumentException( | ||
string.Format( | ||
"Could not find embedded resouce name that ends with '{0}', only found these: {1}", | ||
embeddedResourceNameEndsWith, | ||
string.Join(", ", resourceNames)), | ||
"embeddedResourceNameEndsWith"); | ||
} | ||
|
||
using (var stream = assembly.GetManifestResourceStream(resourceName)) | ||
{ | ||
if (stream == null) | ||
{ | ||
throw new ArgumentException( | ||
string.Format("Failed to open embedded resource stream for resource '{0}'", resourceName)); | ||
} | ||
|
||
using (var streamReader = new StreamReader(stream)) | ||
{ | ||
return streamReader.ReadToEnd(); | ||
} | ||
} | ||
} | ||
} | ||
} |