-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated response to include an array of behaviors (#131)
- Loading branch information
1 parent
1ab59b7
commit dd98b7e
Showing
15 changed files
with
147 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using MbDotNet.Models.Responses; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace MbDotNet.Tests.Models.Responses | ||
{ | ||
[TestClass, TestCategory("Unit")] | ||
public class WaitBehaviorTests | ||
{ | ||
[TestMethod] | ||
public void WaitBehavior_Constructor_SetsLatency() | ||
{ | ||
const int latencyInMilliseconds = 1500; | ||
var behavior = new WaitBehavior(latencyInMilliseconds); | ||
Assert.AreEqual(latencyInMilliseconds, behavior.LatencyInMilliseconds); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,16 +1,9 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace MbDotNet.Models.Responses | ||
{ | ||
/// <summary> | ||
/// A "behavior" response | ||
/// An abstract response behavior | ||
/// </summary> | ||
public class Behavior | ||
public abstract class Behavior | ||
{ | ||
/// <summary> | ||
/// The latency to add to the response | ||
/// </summary> | ||
[JsonProperty("wait", NullValueHandling = NullValueHandling.Ignore)] | ||
public int? LatencyInMilliseconds { get; set; } | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,27 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Newtonsoft.Json; | ||
|
||
namespace MbDotNet.Models.Responses | ||
{ | ||
/// <summary> | ||
/// An abstract representation of a response without a specific protocol | ||
/// </summary> | ||
public abstract class Response | ||
{ | ||
/// <summary> | ||
/// Configured response behaviors | ||
/// </summary> | ||
[JsonProperty("behaviors", NullValueHandling = NullValueHandling.Ignore)] | ||
public IList<Behavior> Behaviors { get; set; } | ||
|
||
/// <summary> | ||
/// Construct a new Response instance | ||
/// </summary> | ||
/// <param name="responseBehaviors">Response behaviors to include on the response</param> | ||
protected Response(IEnumerable<Behavior> responseBehaviors) | ||
{ | ||
Behaviors = responseBehaviors?.ToList(); | ||
} | ||
} | ||
} |
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,25 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace MbDotNet.Models.Responses | ||
{ | ||
/// <summary> | ||
/// The "wait" response behavior | ||
/// </summary> | ||
public class WaitBehavior : Behavior | ||
{ | ||
/// <summary> | ||
/// The latency to add to the response | ||
/// </summary> | ||
[JsonProperty("wait", NullValueHandling = NullValueHandling.Ignore)] | ||
public int LatencyInMilliseconds { get; set; } | ||
|
||
/// <summary> | ||
/// Creates a new WaitBehavior instance | ||
/// </summary> | ||
/// <param name="latencyInMilliseconds">The latency that should be added to the response</param> | ||
public WaitBehavior(int latencyInMilliseconds) | ||
{ | ||
LatencyInMilliseconds = latencyInMilliseconds; | ||
} | ||
} | ||
} |
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