Skip to content

Commit

Permalink
new test
Browse files Browse the repository at this point in the history
  • Loading branch information
yevgenyka committed Feb 13, 2019
1 parent 532bdd0 commit 632e071
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ public async Task Setup()
public void TearDown()
{
_unitTestingKernel.Dispose();
_loadBalancerByEnvironment.Clear();
_serviceDiscovery = null;
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<Compile Include="NinjectExtensionsTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Monitor\RequestTimings.cs" />
<Compile Include="RequestOverridesTests.cs" />
<Compile Include="Serialization\BusinessEntity.cs" />
<Compile Include="Serialization\ExceptionSerializationTests.cs" />
<Compile Include="Serialization\MyServiceException.cs" />
Expand Down
39 changes: 39 additions & 0 deletions tests/Gigya.Microdot.UnitTests/RequestOverridesTests.cs
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");
}
}
}

0 comments on commit 632e071

Please sign in to comment.