-
Notifications
You must be signed in to change notification settings - Fork 31
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 #28 from Kentico/tracking-header-test
Tracking header test
- Loading branch information
Showing
2 changed files
with
46 additions
and
13 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
32 changes: 32 additions & 0 deletions
32
KenticoCloud.ContentManagement.Tests/Modules/Extensions/HttpRequestHeadersExtensionsTests.cs
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,32 @@ | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Net.Http; | ||
|
||
using KenticoCloud.ContentManagement.Modules.HttpClient; | ||
using KenticoCloud.ContentManagement.Modules.Extensions; | ||
|
||
using Xunit; | ||
|
||
namespace KenticoCloud.ContentManagement.Tests | ||
{ | ||
public class HttpRequestHeadersExtensionsTests | ||
{ | ||
[Fact] | ||
public void AddSdkTrackingHeader_CorrectSdkVersionHeaderAdded() | ||
{ | ||
var assembly = typeof(ContentManagementHttpClient).Assembly; | ||
var fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location); | ||
var sdkVersion = fileVersionInfo.ProductVersion; | ||
var sdkPackageId = assembly.GetName().Name; | ||
var httpRequestMessage = new HttpRequestMessage(); | ||
|
||
httpRequestMessage.Headers.AddSdkTrackingHeader(); | ||
|
||
IEnumerable<string> headerContent = new List<string>(); | ||
httpRequestMessage.Headers.TryGetValues("X-KC-SDKID", out headerContent); | ||
|
||
Assert.True(httpRequestMessage.Headers.Contains("X-KC-SDKID")); | ||
Assert.Contains($"nuget.org;{sdkPackageId};{sdkVersion}", headerContent); | ||
} | ||
} | ||
} |