-
Notifications
You must be signed in to change notification settings - Fork 230
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 #236 from gigya/feature/#79416_RequestOverrides_cl…
…one_test new test for requestOverrides shallow clone
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Gigya.Microdot.SharedLogic.HttpService; | ||
using NUnit.Framework; | ||
|
||
namespace Gigya.Microdot.UnitTests | ||
{ | ||
[TestFixture()] | ||
public class RequestOverridesTests | ||
{ | ||
[Test] | ||
public void CheckRequestOverridesShallowClone() | ||
{ | ||
RequestOverrides ro = new RequestOverrides(); | ||
HostOverride ho1 = new HostOverride{Host = "testHost1", Port = 1234, ServiceName = "testService1"}; | ||
ho1.AdditionalProperties = new Dictionary<string, object>(); | ||
ho1.AdditionalProperties.Add("ho1Key", "ho1Value"); | ||
|
||
HostOverride ho2 = new HostOverride{ Host = "testHost2", Port = 1235, ServiceName = "testService2"}; | ||
ho2.AdditionalProperties = new Dictionary<string, object>(); | ||
ho2.AdditionalProperties.Add("ho2Key", "ho2Value"); | ||
|
||
ro.Hosts = new List<HostOverride>(new []{ho1, ho2}); | ||
ro.PreferredEnvironment = "pe1"; | ||
ro.AdditionalProperties = new Dictionary<string, object>(); | ||
ro.AdditionalProperties.Add("roKey", "roValue"); | ||
|
||
RequestOverrides roResult = ro.ShallowCloneWithDifferentPreferredEnvironment("pe2"); | ||
|
||
Assert.AreEqual(ro.Hosts.Count, roResult.Hosts.Count); | ||
Assert.AreEqual(ro.Hosts.Join(roResult.Hosts, h => new {h.Host, h.Port, h.ServiceName}, hr => new {hr.Host, hr.Port, hr.ServiceName}, (h, hr) => hr).Count(), roResult.Hosts.Count); | ||
Assert.AreEqual(roResult.Hosts[0].AdditionalProperties["ho1Key"], "ho1Value"); | ||
Assert.AreEqual(roResult.Hosts[1].AdditionalProperties["ho2Key"], "ho2Value"); | ||
Assert.AreEqual(roResult.AdditionalProperties["roKey"], "roValue"); | ||
Assert.AreEqual(ro.PreferredEnvironment, "pe1"); | ||
Assert.AreEqual(roResult.PreferredEnvironment, "pe2"); | ||
} | ||
} | ||
} |