Skip to content

Commit

Permalink
UnitTest ref#76
Browse files Browse the repository at this point in the history
  • Loading branch information
alona-lip committed Jan 27, 2021
1 parent 19f29b4 commit f23ac31
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Piwik.Tracker.Tests/PiwikTrackerTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Web;
Expand All @@ -24,6 +25,24 @@ public void SetUpTest()
_sut = new PiwikTracker(SiteId, PiwikBaseUrl);
}

[Test]
public void Read_only_first_two_values_from_Cookie()
{
//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 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]
[TestCase(Scopes.Page, 2)]
[TestCase(Scopes.Event, 3)]
Expand Down

0 comments on commit f23ac31

Please sign in to comment.