Skip to content

Commit 005eea8

Browse files
committed
3.5.2 release
1 parent 1a84b31 commit 005eea8

17 files changed

+714
-694
lines changed

QueueIT.KnownUserV3.SDK.Tests/IntegrationConfig/IntegrationConfigHelpersTest.cs

+37-46
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
using QueueIT.KnownUserV3.SDK.IntegrationConfig;
2-
using Rhino.Mocks;
32
using System;
43
using System.Collections.Generic;
54
using System.Collections.Specialized;
6-
using System.Web;
75
using Xunit;
86

97
namespace QueueIT.KnownUserV3.SDK.Tests.IntegrationConfig
@@ -95,28 +93,28 @@ public void Evaluate_Test()
9593
Operator = ComparisonOperatorType.Contains,
9694
ValueToCompare = "1"
9795
};
98-
var cookieCollection = new System.Web.HttpCookieCollection() { };
99-
Assert.False(CookieValidatorHelper.Evaluate(triggerPart, cookieCollection));
96+
var request = new KnownUserTest.MockHttpRequest();
97+
Assert.False(CookieValidatorHelper.Evaluate(triggerPart, request));
10098

101-
cookieCollection.Add(new System.Web.HttpCookie("c5", "5"));
102-
cookieCollection.Add(new System.Web.HttpCookie("c1", "1"));
103-
cookieCollection.Add(new System.Web.HttpCookie("c2", "test"));
104-
Assert.True(CookieValidatorHelper.Evaluate(triggerPart, cookieCollection));
99+
request.CookiesValue.Add("c5", "5");
100+
request.CookiesValue.Add("c1", "1");
101+
request.CookiesValue.Add("c2", "test");
102+
Assert.True(CookieValidatorHelper.Evaluate(triggerPart, request));
105103

106104
triggerPart.ValueToCompare = "5";
107-
Assert.False(CookieValidatorHelper.Evaluate(triggerPart, cookieCollection));
105+
Assert.False(CookieValidatorHelper.Evaluate(triggerPart, request));
108106

109107

110108
triggerPart.ValueToCompare = "Test";
111109
triggerPart.IsIgnoreCase = true;
112110
triggerPart.CookieName = "c2";
113-
Assert.True(CookieValidatorHelper.Evaluate(triggerPart, cookieCollection));
111+
Assert.True(CookieValidatorHelper.Evaluate(triggerPart, request));
114112

115113
triggerPart.ValueToCompare = "Test";
116114
triggerPart.IsIgnoreCase = true;
117115
triggerPart.IsNegative = true;
118116
triggerPart.CookieName = "c2";
119-
Assert.False(CookieValidatorHelper.Evaluate(triggerPart, cookieCollection));
117+
Assert.False(CookieValidatorHelper.Evaluate(triggerPart, request));
120118
}
121119
}
122120

@@ -273,11 +271,10 @@ public void GetMatchedIntegrationConfig_OneTrigger_And_NotMatched()
273271

274272
var url = new Uri("http://test.tesdomain.com:8080/test?q=2");
275273

276-
var httpRequestMock = MockRepository.GenerateMock<HttpRequestBase>();
277-
httpRequestMock.Stub(r => r.Cookies).Return(new HttpCookieCollection());
278-
httpRequestMock.Stub(r => r.UserAgent).Return(string.Empty);
279274

280-
Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock) == null);
275+
276+
Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri,
277+
new KnownUserTest.MockHttpRequest()) == null);
281278
}
282279

283280
[Fact]
@@ -321,10 +318,8 @@ public void GetMatchedIntegrationConfig_OneTrigger_And_Matched()
321318

322319
var url = new Uri("http://test.tesdomain.com:8080/test?q=2");
323320

324-
var httpRequestMock = MockRepository.GenerateMock<HttpRequestBase>();
325-
httpRequestMock.Stub(r => r.Cookies).Return(new HttpCookieCollection() { new HttpCookie("c1", "Value1") });
326-
httpRequestMock.Stub(r => r.UserAgent).Return(string.Empty);
327321

322+
var httpRequestMock = new KnownUserTest.MockHttpRequest() { CookiesValue = new NameValueCollection() { { "c1", "Value1" } } };
328323
Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock).Name == "integration1");
329324
}
330325

@@ -376,10 +371,11 @@ public void GetMatchedIntegrationConfig_OneTrigger_And_NotMatched_UserAgent()
376371

377372
var url = new Uri("http://test.tesdomain.com:8080/test?q=2");
378373

379-
var httpRequestMock = MockRepository.GenerateMock<HttpRequestBase>();
380-
httpRequestMock.Stub(r => r.Cookies).Return(new HttpCookieCollection() { new HttpCookie("c1", "Value1") });
381-
httpRequestMock.Stub(r => r.UserAgent).Return("bot.html google.com googlebot test");
382-
374+
var httpRequestMock = new KnownUserTest.MockHttpRequest()
375+
{
376+
CookiesValue = new NameValueCollection() { { "c1", "Value1" } },
377+
UserAgent = "bot.html google.com googlebot test"
378+
};
383379
Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock) == null);
384380
}
385381

@@ -432,12 +428,12 @@ public void GetMatchedIntegrationConfig_OneTrigger_And_NotMatched_HttpHeader()
432428

433429
var url = new Uri("http://test.tesdomain.com:8080/test?q=2");
434430

435-
var httpRequestMock = MockRepository.GenerateMock<HttpRequestBase>();
436-
httpRequestMock.Stub(r => r.Cookies).Return(new HttpCookieCollection() { new HttpCookie("c1", "Value1") });
437-
var httpHeaders = new NameValueCollection();
438-
httpHeaders.Add("Akamai-bot", "bot");
439-
httpRequestMock.Stub(r => r.Headers).Return(httpHeaders);
440431

432+
var httpRequestMock = new KnownUserTest.MockHttpRequest()
433+
{
434+
CookiesValue = new NameValueCollection() { { "c1", "Value1" } },
435+
Headers = new NameValueCollection() { { "Akamai-bot", "bot" } }
436+
};
441437
Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock) == null);
442438
}
443439

@@ -481,10 +477,11 @@ public void GetMatchedIntegrationConfig_OneTrigger_Or_NotMatched()
481477

482478
var url = new Uri("http://test.tesdomain.com:8080/test?q=2");
483479

484-
var httpRequestMock = MockRepository.GenerateMock<HttpRequestBase>();
485-
httpRequestMock.Stub(r => r.Cookies).Return(new HttpCookieCollection() { new HttpCookie("c2", "value1") });
486-
httpRequestMock.Stub(r => r.UserAgent).Return(string.Empty);
487480

481+
var httpRequestMock = new KnownUserTest.MockHttpRequest()
482+
{
483+
CookiesValue = new NameValueCollection() { { "c2", "value1" } }
484+
};
488485
Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock) == null);
489486
}
490487

@@ -526,10 +523,10 @@ public void GetMatchedIntegrationConfig_OneTrigger_Or_Matched()
526523

527524

528525
var url = new Uri("http://test.tesdomain.com:8080/test?q=2");
529-
var httpRequestMock = MockRepository.GenerateMock<HttpRequestBase>();
530-
httpRequestMock.Stub(r => r.Cookies).Return(new HttpCookieCollection() { new HttpCookie("c1", "value1") });
531-
httpRequestMock.Stub(r => r.UserAgent).Return(string.Empty);
532-
526+
var httpRequestMock = new KnownUserTest.MockHttpRequest()
527+
{
528+
CookiesValue = new NameValueCollection() { { "c1", "value1" } }
529+
};
533530
Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock).Name == "integration1");
534531
}
535532

@@ -580,10 +577,7 @@ public void GetMatchedIntegrationConfig_TwoTriggers_Matched()
580577

581578
var url = new Uri("http://test.tesdomain.com:8080/test?q=2");
582579

583-
var httpRequestMock = MockRepository.GenerateMock<HttpRequestBase>();
584-
httpRequestMock.Stub(r => r.Cookies).Return(new HttpCookieCollection());
585-
httpRequestMock.Stub(r => r.UserAgent).Return(string.Empty);
586-
580+
var httpRequestMock = new KnownUserTest.MockHttpRequest();
587581
Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock).Name == "integration1", string.Empty);
588582
}
589583

@@ -633,10 +627,7 @@ public void GetMatchedIntegrationConfig_TwoTriggers_NotMatched()
633627

634628
var url = new Uri("http://test.tesdomain.com:8080/test?q=2");
635629

636-
var httpRequestMock = MockRepository.GenerateMock<HttpRequestBase>();
637-
httpRequestMock.Stub(r => r.Cookies).Return(new HttpCookieCollection());
638-
httpRequestMock.Stub(r => r.UserAgent).Return(string.Empty);
639-
630+
var httpRequestMock = new KnownUserTest.MockHttpRequest();
640631
Assert.True(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock) == null);
641632
}
642633

@@ -712,10 +703,10 @@ public void GetMatchedIntegrationConfig_ThreeIntegrationsInOrder_SecondMatched()
712703

713704
var url = new Uri("http://test.tesdomain.com:8080/test?q=2");
714705

715-
var httpRequestMock = MockRepository.GenerateMock<HttpRequestBase>();
716-
httpRequestMock.Stub(r => r.Cookies).Return(new HttpCookieCollection() { new HttpCookie("c1") { Value = "Value1" } });
717-
httpRequestMock.Stub(r => r.UserAgent).Return(string.Empty);
718-
706+
var httpRequestMock = new KnownUserTest.MockHttpRequest()
707+
{
708+
CookiesValue = new NameValueCollection() { { "c1", "Value1" } }
709+
};
719710
Assert.False(testObject.GetMatchedIntegrationConfig(customerIntegration, url.AbsoluteUri, httpRequestMock).Name == "integration2");
720711
}
721712
}

0 commit comments

Comments
 (0)