Skip to content

Commit

Permalink
UnitTest Extension ref matomo-org#76
Browse files Browse the repository at this point in the history
  • Loading branch information
alona-lip committed Jan 27, 2021
1 parent f23ac31 commit 3b3c0cb
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions Piwik.Tracker.Tests/PiwikTrackerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void SetUpTest()
}

[Test]
public void Read_only_first_two_values_from_Cookie()
public void GetVisitorId_TwoComponentCookie_ReturnsCookieId()
{
//Arrange
HttpContext.Current = new HttpContext(new HttpRequest("filename", "http://url.com", "query"), new HttpResponse(new StringWriter()));
Expand All @@ -35,12 +35,25 @@ public void Read_only_first_two_values_from_Cookie()

//Act
var actual = _sut.GetVisitorId();
var request = _sut.GetRequest(SiteId);

//Assert
Assert.That(actual, Is.Not.Null.Or.Empty);
Assert.That(actual, Is.EqualTo("d32ffdf363c2f313"));
Assert.That(request, Does.Contain("&_id=" + actual));
}

[Test]
public void GetRequest_TwoComponentCookie_SetsCorrectCookie()
{
//Arrange
HttpContext.Current = new HttpContext(new HttpRequest("filename", "http://url.com", "query"), new HttpResponse(new StringWriter()));
var cookies = HttpContext.Current.Request.Cookies;
cookies.Add(new HttpCookie("_pk_id.1.4ea4", "d32ffdf363c2f313.1610980363."));

//Act
var request = _sut.GetRequest(SiteId);

//Assert
Assert.That(request, Does.Contain("&_id=d32ffdf363c2f313"));
}

[Test]
Expand Down

0 comments on commit 3b3c0cb

Please sign in to comment.