Skip to content

Commit

Permalink
Move method from ConsumerTest to CommunicationTestBase
Browse files Browse the repository at this point in the history
References #8
  • Loading branch information
andreashuber-lawo committed Jan 8, 2016
1 parent 9f505eb commit 465e1c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
7 changes: 1 addition & 6 deletions Lawo.EmberPlusSharpTest/Model/ConsumerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,12 +1328,7 @@ private static byte[] GetPayload(string payloadXmlName, params object[] args)

private static string GetXml(string payloadXmlName)
{
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
typeof(ModelPayloads), payloadXmlName))
using (var reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
return GetContent<ModelPayloads>(payloadXmlName);
}

private static byte[] ToPayload(string xml)
Expand Down
19 changes: 17 additions & 2 deletions Lawo.EmberPlusSharpTest/S101/CommunicationTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ protected static S101Message KeepAliveResponseMessage

/// <summary>Uses <see cref="S101Robot"/> to simulate a provider communicating with the <see cref="S101Client"/>
/// object passed to <paramref name="testCallback"/>.</summary>
/// <typeparam name="TResourceNamespace">The type whose namespace is used to scope
/// <paramref name="logXmlName"/> in the manifest resources.</typeparam>
/// <typeparam name="TResourceNamespace">The type whose namespace is used to scope <paramref name="logXmlName"/>
/// in the manifest resources.</typeparam>
[SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "There's no clean alternative.")]
protected static Task TestWithRobot<TResourceNamespace>(
Func<S101Client, Task> testCallback,
Expand Down Expand Up @@ -266,6 +266,21 @@ protected byte GetRandomByteExcept(params byte[] exceptions)
return result;
}

/// <summary>Reads and returns the contents of the resource text file identified by <paramref name="fileName"/>.
/// </summary>
/// <typeparam name="TResourceNamespace">The type whose namespace is used to scope <paramref name="fileName"/>
/// in the manifest resources.</typeparam>
[SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter", Justification = "There's no clean alternative.")]
protected static string GetContent<TResourceNamespace>(string fileName)
{
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
typeof(TResourceNamespace), fileName))
using (var reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////

private static Task<int> Read(
Expand Down

0 comments on commit 465e1c7

Please sign in to comment.